diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-12-01 17:16:11 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-12-01 17:16:25 +0000 |
commit | 0ab83056ad2261d6eb2690b35ccfc0a64915c25a (patch) | |
tree | 1448a96fb3a245ef22ae09a4b8e1f189abbc8347 /rules | |
parent | 6750b4c303c84ff82fa578ad8d49f8f84e5bcf0d (diff) | |
download | rspamd-0ab83056ad2261d6eb2690b35ccfc0a64915c25a.tar.gz rspamd-0ab83056ad2261d6eb2690b35ccfc0a64915c25a.zip |
[Feature] Add EXT_CSS rule
Diffstat (limited to 'rules')
-rw-r--r-- | rules/html.lua | 32 |
1 files changed, 32 insertions, 0 deletions
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 |