Browse Source

[Fix] Fix usage of util.parse_mail_address

tags/1.7.3
Vsevolod Stakhov 6 years ago
parent
commit
51e2a8c056

+ 3
- 3
rules/headers_checks.lua View File

@@ -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

+ 2
- 2
rules/misc.lua View File

@@ -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

+ 2
- 2
rules/regexp/compromised_hosts.lua View File

@@ -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

+ 2
- 1
src/lua/lua_util.c View File

@@ -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);

+ 1
- 1
src/plugins/lua/emails.lua View File

@@ -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])

Loading…
Cancel
Save