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 GitHub
commit 99788ee504
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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