From: Vsevolod Stakhov Date: Mon, 17 Jun 2019 16:42:20 +0000 (+0100) Subject: [Fix] Clickhouse: Fix quoting X-Git-Tag: 2.0~767 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5c81f0ce3d64085efebd0becd2d017697fc7edfd;p=thirdparty%2Frspamd.git [Fix] Clickhouse: Fix quoting Issue: #2928 --- diff --git a/lualib/lua_clickhouse.lua b/lualib/lua_clickhouse.lua index e7dbed9d38..1aca0f7199 100644 --- a/lualib/lua_clickhouse.lua +++ b/lualib/lua_clickhouse.lua @@ -44,7 +44,12 @@ end local function clickhouse_quote(str) if str then - return str:gsub('[\'\\]', '\\%1'):lower() + return str:gsub('[\'\\\n\t]', { + ['\''] = '\\\'', + ['\\'] = '\\', + ['\n'] = '\\n', + ['\t'] = '\\t' + }):lower() end return '' @@ -71,6 +76,8 @@ local function row_to_tsv(row) row[i] = '[' .. array_to_string(elt) .. ']' elseif type(elt) == 'number' then row[i] = ch_number(elt) + else + row[i] = clickhouse_quote(elt) end end