diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-04-20 15:26:46 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-04-20 15:26:46 +0100 |
commit | 60d075965347f1be5ec35fc72f8d3187151d0e1b (patch) | |
tree | 2d0e52c0345421523f56cdc2e3a483e668a8f0b2 /lualib | |
parent | 86d8939ad4371f80d1b034a84224faf5d173cdb3 (diff) | |
download | rspamd-60d075965347f1be5ec35fc72f8d3187151d0e1b.tar.gz rspamd-60d075965347f1be5ec35fc72f8d3187151d0e1b.zip |
[Fix] Ical: Do not extract urls from all flags using merely specific ones
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_content/ical.lua | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/lualib/lua_content/ical.lua b/lualib/lua_content/ical.lua index 5ee37a491..ef8da5068 100644 --- a/lualib/lua_content/ical.lua +++ b/lualib/lua_content/ical.lua @@ -42,19 +42,34 @@ local function extract_text_data(specific) return table.concat(tbl, '\n') end + +-- Keys that can have visible urls +local url_keys = lua_util.list_to_hash{ + 'description', + 'location', + 'summary', + 'organizer', + 'organiser', + 'attendee', + 'url' +} + local function process_ical(input, mpart, task) local control={n='\n', r=''} local rspamd_url = require "rspamd_url" local escaper = l.Ct((gen_grammar() / function(key, value) value = value:gsub("\\(.)", control) - key = key:lower() - local local_urls = rspamd_url.all(task:get_mempool(), value) - - if local_urls and #local_urls > 0 then - for _,u in ipairs(local_urls) do - lua_util.debugm(N, task, 'ical: found URL in ical %s', - tostring(u)) - task:inject_url(u, mpart) + key = key:lower():match('^([^;]+)') + + if key and url_keys[key] then + local local_urls = rspamd_url.all(task:get_mempool(), value) + + if local_urls and #local_urls > 0 then + for _,u in ipairs(local_urls) do + lua_util.debugm(N, task, 'ical: found URL in ical key "%s": %s', + key, tostring(u)) + task:inject_url(u, mpart) + end end end lua_util.debugm(N, task, 'ical: ical key %s = "%s"', |