summaryrefslogtreecommitdiffstats
path: root/rules
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-03-16 11:39:10 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-03-16 11:39:10 +0000
commit028e4ecefef3491202d16725b0ce780f5d6ba48d (patch)
tree912ab98869cb33bc9b1e3d3e8f22063826cf2006 /rules
parent10fb4d1a18a0a0573ad84a5ec4e5dd2ba55fdaa3 (diff)
downloadrspamd-028e4ecefef3491202d16725b0ce780f5d6ba48d.tar.gz
rspamd-028e4ecefef3491202d16725b0ce780f5d6ba48d.zip
[Rules] Another fix to HTTP_TO_HTTPS rule
Diffstat (limited to 'rules')
-rw-r--r--rules/html.lua20
1 files changed, 10 insertions, 10 deletions
diff --git a/rules/html.lua b/rules/html.lua
index 5430f49b7..cffb2f94a 100644
--- a/rules/html.lua
+++ b/rules/html.lua
@@ -368,10 +368,10 @@ rspamd_config.EXT_CSS = {
description = 'Message contains external CSS reference'
}
+local https_re = rspamd_regexp.create_cached('/^https:/i')
+
rspamd_config.HTTP_TO_HTTPS = {
callback = function(task)
- local http_re = rspamd_regexp.create_cached('/^http[^s]/i')
- local https_re = rspamd_regexp.create_cached('/^https:/i')
local found_opts
local tp = task:get_text_parts() or {}
@@ -382,25 +382,25 @@ rspamd_config.HTTP_TO_HTTPS = {
local found = false
- hc:foreach_tag('a', function (tag, length)
+ hc:foreach_tag('a', function (tag, _)
-- Skip this loop if we already have a match
if (found) then return true end
local c = tag:get_content()
if (c) then
- if (not http_re:match(c)) then return false end
+ if (not https_re:match(c)) then return false end
local u = tag:get_extra()
if (not u) then return false end
local url_proto = u:get_protocol()
- if (not url_proto:match('^http')) then return false end
+
+ if (not url_proto == 'http') then return false end
-- Capture matches for http in href to https in visible part only
- if ((https_re:match(c) and url_proto == 'http')) then
- found = true
- found_opts = u:get_host()
- return true
- end
+ found = true
+ found_opts = u:get_host()
+ return true
end
+
return false
end)