]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Clickhouse: Fix quoting
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 17 Jun 2019 16:42:20 +0000 (17:42 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 17 Jun 2019 16:42:20 +0000 (17:42 +0100)
Issue: #2928

lualib/lua_clickhouse.lua

index e7dbed9d38f80c93705f9158bc838250cf6be3f5..1aca0f7199aad44be312fb7cb407bc4bfbddf673 100644 (file)
@@ -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