From: Vsevolod Stakhov Date: Thu, 1 Dec 2016 17:16:11 +0000 (+0000) Subject: [Feature] Add EXT_CSS rule X-Git-Tag: 1.4.2~15 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0ab83056ad2261d6eb2690b35ccfc0a64915c25a;p=rspamd.git [Feature] Add EXT_CSS rule --- diff --git a/rules/html.lua b/rules/html.lua index ad9bd4d42..142cb293c 100644 --- a/rules/html.lua +++ b/rules/html.lua @@ -232,3 +232,35 @@ rspamd_config.R_WHITE_ON_WHITE = { group = 'html', description = 'Message contains low contrast text' } + +rspamd_config.EXT_CSS = { + callback = function(task) + local regexp_lib = require "rspamd_regexp" + local re = regexp_lib.create_cached('/^.*\\.css(?:[?#].*)?$/i') + local tp = task:get_text_parts() -- get text parts in a message + local ret = false + for _,p in ipairs(tp) do -- iterate over text parts array using `ipairs` + if p:is_html() and p:get_html() then -- if the current part is html part + local hc = p:get_html() -- we get HTML context + hc:foreach_tag({'link'}, function(tag) + local bl = tag:get_extra() + if bl then + local s = tostring(bl) + if s and re:match(s) then + ret = true + end + end + + return ret -- Continue search + end) + + end + end + + return ret + end, + + score = 1.0, + group = 'html', + description = 'Message contains external CSS reference' +} \ No newline at end of file