]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Fix usage of util.parse_mail_address
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 31 Mar 2018 16:48:50 +0000 (17:48 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 31 Mar 2018 16:48:50 +0000 (17:48 +0100)
rules/headers_checks.lua
rules/misc.lua
rules/regexp/compromised_hosts.lua
src/lua/lua_util.c
src/plugins/lua/emails.lua

index a97d7483ff3d43f8b928bf2b48fb2b3150787fbc..065a9d8f79641f9dc869e5e9c9813433cc9c899c 100644 (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
index 9d6cd01c23970f7416ab29c5b4a14e229c231def..f4591c9a29804007a2f875592b73e72599c68468 100644 (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
index 67101a80d33691eac8909a6463dadceafc2b83ec..46a192978554838003dcc0f8b76c61669c60953d 100644 (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
index 64b25c14add6963085715f00fdfe023c893e1f22..50fa6d3979a604d6ffd39a1f2efb321ec839f138 100644 (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);
index 12e94a9323c5a15009f0f0b0aa302c77135cc1aa..f4d95d0baead62cb5aecc09300dea28fcf898dd9 100644 (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])