]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Fix set_addr validation to prevent malformed addresses 5655/head
authorVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 8 Oct 2025 10:16:32 +0000 (11:16 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 8 Oct 2025 10:16:32 +0000 (11:16 +0100)
The set_addr function now properly checks that both addr.user and addr.domain
are non-empty strings before constructing addr.addr and addr.raw. This prevents
creating malformed addresses like '@domain.com' when addr.user is empty, and
ensures consistent state when addr.domain is empty.

src/plugins/lua/aliases.lua

index ed665c2a48e634245e7e63584cd8cd2e8551197f..c65e72962b2952850ced1c003d9cab5dea3b65dd 100644 (file)
@@ -297,8 +297,8 @@ local function set_addr(addr, new_user, new_domain)
     addr.domain = new_domain
   end
 
-  -- Only update if we have both user and domain
-  if addr.user and addr.domain and addr.domain ~= '' then
+  -- Only update if we have both user and domain as non-empty strings
+  if addr.user and addr.user ~= '' and addr.domain and addr.domain ~= '' then
     addr.addr = string.format('%s@%s', addr.user, addr.domain)
 
     if addr.name and #addr.name > 0 then