Escape %00 / \0 in dbQuote (#18015) [backport:1.4]

Fix https://github.com/nim-lang/Nim/issues/17925
This commit is contained in:
Thomas T. Jarløv
2021-05-15 21:26:15 +02:00
committed by ringabout
parent 2b6e1d4836
commit 9f35bb3968

View File

@@ -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, '\'')