From d35ff02b8bca501e89a41b71ce12e82116e9eec9 Mon Sep 17 00:00:00 2001 From: Robert Schulze Date: Fri, 5 May 2023 12:35:51 +0000 Subject: [PATCH] Fix writeAnyEscapedString if quote_character is a meta character Function writeAnyEscapedString() escapes - quote_character with itself or with a backslash, depending on template parameter escape_quote_with_quote - some metacharacters with backslash. If quote_character is a metacharacter, the code previously always quoted with backslash, independently of escape_quote_with_quote. I didn't find places which do this but better be on the safe side. --- src/IO/WriteHelpers.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/IO/WriteHelpers.h b/src/IO/WriteHelpers.h index be149394b20..cdbc952690c 100644 --- a/src/IO/WriteHelpers.h +++ b/src/IO/WriteHelpers.h @@ -316,6 +316,15 @@ void writeAnyEscapedString(const char * begin, const char * end, WriteBuffer & b pos = next_pos; switch (*pos) { + case quote_character: + { + if constexpr (escape_quote_with_quote) + writeChar(quote_character, buf); + else + writeChar('\\', buf); + writeChar(quote_character, buf); + break; + } case '\b': writeChar('\\', buf); writeChar('b', buf); @@ -344,15 +353,6 @@ void writeAnyEscapedString(const char * begin, const char * end, WriteBuffer & b writeChar('\\', buf); writeChar('\\', buf); break; - case quote_character: - { - if constexpr (escape_quote_with_quote) - writeChar(quote_character, buf); - else - writeChar('\\', buf); - writeChar(quote_character, buf); - break; - } default: writeChar(*pos, buf); }