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
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
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
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
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
-- 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
-- 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
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`
* - `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);
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])