diff options
author | Thomas T. Jarløv <ThomasTJdev@users.noreply.github.com> | 2021-05-15 21:26:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-15 21:26:15 +0200 |
commit | 99788ee50426946d954e7311f567414b39f7b8d7 (patch) | |
tree | 6c8abc05a3344729b1875479adba0b8e25df7124 | |
parent | 3824fd3f9a303bc885a6f1f2eb7aa28fb5460cb7 (diff) | |
download | Nim-99788ee50426946d954e7311f567414b39f7b8d7.tar.gz |
Escape `%00` / `\0` in `dbQuote` (#18015) [backport:1.4]
Fix https://github.com/nim-lang/Nim/issues/17925
-rw-r--r-- | lib/impure/db_postgres.nim | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/impure/db_postgres.nim b/lib/impure/db_postgres.nim index cb9e5414a..4edeac2fc 100644 --- a/lib/impure/db_postgres.nim +++ b/lib/impure/db_postgres.nim @@ -110,7 +110,9 @@ proc dbQuote*(s: string): string = ## DB quotes the string. result = "'" for c in items(s): - if c == '\'': add(result, "''") + case c + of '\'': add(result, "''") + of '\0': add(result, "\\0") else: add(result, c) add(result, '\'') |