From 99788ee50426946d954e7311f567414b39f7b8d7 Mon Sep 17 00:00:00 2001 From: "Thomas T. Jarløv" Date: Sat, 15 May 2021 21:26:15 +0200 Subject: Escape `%00` / `\0` in `dbQuote` (#18015) [backport:1.4] Fix https://github.com/nim-lang/Nim/issues/17925 --- lib/impure/db_postgres.nim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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, '\'') -- cgit 1.4.1-2-gfad0