aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_clickhouse.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-06-17 17:42:20 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-06-17 17:42:20 +0100
commit5c81f0ce3d64085efebd0becd2d017697fc7edfd (patch)
treef34d19792a6d7ebca1567b39b42c5673bfe39df6 /lualib/lua_clickhouse.lua
parente39008c291e4b7bede0328df76fccd06b33c5703 (diff)
downloadrspamd-5c81f0ce3d64085efebd0becd2d017697fc7edfd.tar.gz
rspamd-5c81f0ce3d64085efebd0becd2d017697fc7edfd.zip
[Fix] Clickhouse: Fix quoting
Issue: #2928
Diffstat (limited to 'lualib/lua_clickhouse.lua')
-rw-r--r--lualib/lua_clickhouse.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/lualib/lua_clickhouse.lua b/lualib/lua_clickhouse.lua
index e7dbed9d3..1aca0f719 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