aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-31 17:48:50 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-31 17:48:50 +0100
commit51e2a8c05682c0bbbfb940681bf12b93b4719f7f (patch)
treedc04847adb8be1be153f681344d924c5feb0b551
parent7c09818f4165382cbd65a6a33b655a2def0ffc65 (diff)
downloadrspamd-51e2a8c05682c0bbbfb940681bf12b93b4719f7f.tar.gz
rspamd-51e2a8c05682c0bbbfb940681bf12b93b4719f7f.zip
[Fix] Fix usage of util.parse_mail_address
-rw-r--r--rules/headers_checks.lua6
-rw-r--r--rules/misc.lua4
-rw-r--r--rules/regexp/compromised_hosts.lua4
-rw-r--r--src/lua/lua_util.c3
-rw-r--r--src/plugins/lua/emails.lua2
5 files changed, 10 insertions, 9 deletions
diff --git a/rules/headers_checks.lua b/rules/headers_checks.lua
index a97d7483f..065a9d8f7 100644
--- a/rules/headers_checks.lua
+++ b/rules/headers_checks.lua
@@ -184,7 +184,7 @@ local check_replyto_id = rspamd_config:register_callback_symbol('CHECK_REPLYTO',
function (task)
local replyto = get_raw_header(task, 'Reply-To')
if not replyto then return false end
- local rt = util.parse_mail_address(replyto)
+ local rt = util.parse_mail_address(replyto, task:get_mempool())
if not (rt and rt[1] and (string.len(rt[1].addr) > 0)) then
task:insert_result('REPLYTO_UNPARSEABLE', 1.0)
return false
@@ -451,7 +451,7 @@ rspamd_config.HEADER_RCONFIRM_MISMATCH = {
local header_cread = nil
if cread then
- local headers_cread = util.parse_mail_address(cread)
+ local headers_cread = util.parse_mail_address(cread, task:get_mempool())
if headers_cread then header_cread = headers_cread[1] end
end
@@ -480,7 +480,7 @@ rspamd_config.HEADER_FORGED_MDN = {
end
-- Parse mail addr
- local headers_mdn = util.parse_mail_address(mdn)
+ local headers_mdn = util.parse_mail_address(mdn, task:get_mempool())
if headers_mdn and not header_rp then return true end
if header_rp and not headers_mdn then return false end
diff --git a/rules/misc.lua b/rules/misc.lua
index 9d6cd01c2..f4591c9a2 100644
--- a/rules/misc.lua
+++ b/rules/misc.lua
@@ -487,7 +487,7 @@ local check_from_display_name = rspamd_config:register_symbol{
local from = task:get_from(2)
if not (from and from[1] and from[1].name) then return false end
-- See if we can parse an email address from the name
- local parsed = util.parse_mail_address(from[1].name)
+ local parsed = util.parse_mail_address(from[1].name, task:get_mempool())
if not parsed then return false end
if not (parsed[1] and parsed[1]['addr']) then return false end
-- Make sure we did not mistake e.g. <something>@<name> for an email address
@@ -567,7 +567,7 @@ rspamd_config.SPOOF_REPLYTO = {
end
if not found_fromdom then return false end
-- Parse Reply-To header
- local parsed = ((util.parse_mail_address(rt) or E)[1] or E).domain
+ local parsed = ((util.parse_mail_address(rt, task:get_mempool()) or E)[1] or E).domain
if not parsed then return false end
-- Reply-To domain must be different to From domain
if not util.strequal_caseless(parsed, from[1].domain) then
diff --git a/rules/regexp/compromised_hosts.lua b/rules/regexp/compromised_hosts.lua
index 67101a80d..46a192978 100644
--- a/rules/regexp/compromised_hosts.lua
+++ b/rules/regexp/compromised_hosts.lua
@@ -177,7 +177,7 @@ rspamd_config.FROM_SERVICE_ACCT = {
-- Sender
local sender = task:get_header('Sender')
if sender then
- local s = util.parse_mail_address(sender)
+ local s = util.parse_mail_address(sender, task:get_mempool())
if (s and s[1]) then
if (re:match(s[1].addr)) then return true end
end
@@ -185,7 +185,7 @@ rspamd_config.FROM_SERVICE_ACCT = {
-- Reply-To
local replyto = task:get_header('Reply-To')
if replyto then
- local rt = util.parse_mail_address(replyto)
+ local rt = util.parse_mail_address(replyto, task:get_mempool())
if (rt and rt[1]) then
if (re:match(rt[1].addr)) then return true end
end
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index 64b25c14a..50fa6d397 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -183,7 +183,7 @@ LUA_FUNCTION_DEF (util, get_tld);
LUA_FUNCTION_DEF (util, glob);
/***
- * @function util.parse_mail_address(str)
+ * @function util.parse_mail_address(str, pool)
* Parses email address and returns a table of tables in the following format:
*
* - `name` - name of internet address in UTF8, e.g. for `Vsevolod Stakhov <blah@foo.com>` it returns `Vsevolod Stakhov`
@@ -192,6 +192,7 @@ LUA_FUNCTION_DEF (util, glob);
* - `domain` - domain part (if present), e.g. `foo.com`
*
* @param {string} str input string
+ * @param {rspamd_mempool} pool memory pool to use
* @return {table/tables} parsed list of mail addresses
*/
LUA_FUNCTION_DEF (util, parse_mail_address);
diff --git a/src/plugins/lua/emails.lua b/src/plugins/lua/emails.lua
index 12e94a932..f4d95d0ba 100644
--- a/src/plugins/lua/emails.lua
+++ b/src/plugins/lua/emails.lua
@@ -157,7 +157,7 @@ local function gen_check_emails(rule)
local replyto = get_raw_header('Reply-To')
if not replyto then return false end
- local rt = util.parse_mail_address(replyto)
+ local rt = util.parse_mail_address(replyto, task:get_mempool())
if rt and rt[1] then
rspamd_lua_utils.remove_email_aliases(rt[1])