]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Aliases: prevent creation of malformed email addresses
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 3 Oct 2025 10:49:51 +0000 (11:49 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 3 Oct 2025 10:49:51 +0000 (11:49 +0100)
* [Fix] set_addr() now validates that both user and domain exist before
  creating email address, avoiding malformed "user@" format
* [Project] Add rule to .cursor: do not amend commits to avoid force push

.cursor/rules/commits-and-tags.mdc
src/plugins/lua/aliases.lua

index 35b6157be5b3627f506fc53f52cd1be4c1b1205a..287433115b31c709aba81020bc6a98bf75299dde 100644 (file)
@@ -12,24 +12,26 @@ All commits in the Rspamd project follow a structured format with tags that indi
 
 Use one of the following tags at the beginning of commit messages:
 
-- `[Feature]` - New features and capabilities
-- `[Fix]` - Bug fixes and corrections
-- `[CritFix]` - Critical bug fixes that need immediate attention
-- `[Minor]` - Minor changes, tweaks, or version updates
-- `[Project]` - Project-wide changes, refactoring, or infrastructure updates
-- `[Rework]` - Major reworking of existing functionality
-- `[Conf]` - Configuration changes or updates
-- `[Test]` - Test additions or modifications
-- `[Rules]` - Changes to spam detection rules
+-   `[Feature]` - New features and capabilities
+-   `[Fix]` - Bug fixes and corrections
+-   `[CritFix]` - Critical bug fixes that need immediate attention
+-   `[Minor]` - Minor changes, tweaks, or version updates
+-   `[Project]` - Project-wide changes, refactoring, or infrastructure updates
+-   `[Rework]` - Major reworking of existing functionality
+-   `[Conf]` - Configuration changes or updates
+-   `[Test]` - Test additions or modifications
+-   `[Rules]` - Changes to spam detection rules
 
 ## Commit Message Examples
 
 **Version updates:**
+
 ```
 [Minor] Update version of rspamd to X.Y.Z
 ```
 
 **Single-line changes:**
+
 ```
 [Fix] Fix memory leak in dkim module
 [Feature] Add support for encrypted maps
@@ -37,6 +39,7 @@ Use one of the following tags at the beginning of commit messages:
 ```
 
 **Multi-line changes (for releases or complex changes):**
+
 ```
 Release X.Y.Z
 
@@ -50,9 +53,9 @@ Release X.Y.Z
 
 **All commits and tags MUST be signed with GPG:**
 
-- Use `git commit -S` to sign commits
-- Use `git tag -s <tagname>` to sign tags
-- Verify signatures with `git log --show-signature` or `git tag -v <tagname>`
+-   Use `git commit -S` to sign commits
+-   Use `git tag -s <tagname>` to sign tags
+-   Verify signatures with `git log --show-signature` or `git tag -v <tagname>`
 
 ## Release Process
 
@@ -68,10 +71,11 @@ X.Y.Z: DD MMM YYYY
 ```
 
 Format rules:
-- Date format: `DD MMM YYYY` (e.g., `30 Sep 2025`)
-- Each entry starts with `  * [Tag]` (two spaces, asterisk, space, tag)
-- Group entries by tag type
-- Keep descriptions concise but informative
+
+-   Date format: `DD MMM YYYY` (e.g., `30 Sep 2025`)
+-   Each entry starts with `  * [Tag]` (two spaces, asterisk, space, tag)
+-   Group entries by tag type
+-   Keep descriptions concise but informative
 
 ### 2. Create Release Commit
 
@@ -128,24 +132,25 @@ set(RSPAMD_VERSION_MINOR Y)
 set(RSPAMD_VERSION_PATCH Z)
 ```
 
-- **MAJOR**: Incompatible API changes or major breaking changes
-- **MINOR**: New features in a backward-compatible manner
-- **PATCH**: Backward-compatible bug fixes
+-   **MAJOR**: Incompatible API changes or major breaking changes
+-   **MINOR**: New features in a backward-compatible manner
+-   **PATCH**: Backward-compatible bug fixes
 
 ## Pre-commit Hooks
 
-- If pre-commit hooks fail on unrelated issues, use `--no-verify` flag
-- Only use `--no-verify` when necessary and ensure code quality manually
-- Pre-commit hooks check:
-  - Trailing whitespace
-  - Line endings
-  - ClangFormat
-  - LuaCheck
+-   If pre-commit hooks fail on unrelated issues, use `--no-verify` flag
+-   Only use `--no-verify` when necessary and ensure code quality manually
+-   Pre-commit hooks check:
+    -   Trailing whitespace
+    -   Line endings
+    -   ClangFormat
+    -   LuaCheck
 
 ## General Guidelines
 
-- Write clear, descriptive commit messages
-- One logical change per commit
-- Reference issue numbers when applicable
-- Keep commit history clean and meaningful
-- Always sign commits and tags with GPG
\ No newline at end of file
+-   Write clear, descriptive commit messages
+-   One logical change per commit
+-   Reference issue numbers when applicable
+-   Keep commit history clean and meaningful
+-   Always sign commits and tags with GPG
+-   Do NOT amend commits to avoid force push (create new commits instead)
index d1a3dcd9c624d3db9d30489369b79ff8814299f9..ed665c2a48e634245e7e63584cd8cd2e8551197f 100644 (file)
@@ -297,16 +297,20 @@ local function set_addr(addr, new_user, new_domain)
     addr.domain = new_domain
   end
 
-  if addr.domain then
+  -- Only update if we have both user and domain
+  if addr.user and addr.domain and addr.domain ~= '' then
     addr.addr = string.format('%s@%s', addr.user, addr.domain)
-  else
-    addr.addr = string.format('%s@', addr.user)
-  end
 
-  if addr.name and #addr.name > 0 then
-    addr.raw = string.format('"%s" <%s>', addr.name, addr.addr)
+    if addr.name and #addr.name > 0 then
+      addr.raw = string.format('"%s" <%s>', addr.name, addr.addr)
+    else
+      addr.raw = string.format('<%s>', addr.addr)
+    end
   else
-    addr.raw = string.format('<%s>', addr.addr)
+    -- Invalid address - don't modify
+    lua_util.debugm(N, rspamd_config,
+        'set_addr: invalid address user=%s domain=%s, not modifying',
+        addr.user or 'nil', addr.domain or 'nil')
   end
 end