From: Vsevolod Stakhov Date: Fri, 3 Oct 2025 10:49:51 +0000 (+0100) Subject: [Fix] Aliases: prevent creation of malformed email addresses X-Git-Tag: 3.14.0~88^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1436881883abd51751cd9eb6a0cd040807c748cf;p=thirdparty%2Frspamd.git [Fix] Aliases: prevent creation of malformed email addresses * [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 --- diff --git a/.cursor/rules/commits-and-tags.mdc b/.cursor/rules/commits-and-tags.mdc index 35b6157be5..287433115b 100644 --- a/.cursor/rules/commits-and-tags.mdc +++ b/.cursor/rules/commits-and-tags.mdc @@ -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 ` to sign tags -- Verify signatures with `git log --show-signature` or `git tag -v ` +- Use `git commit -S` to sign commits +- Use `git tag -s ` to sign tags +- Verify signatures with `git log --show-signature` or `git tag -v ` ## 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) diff --git a/src/plugins/lua/aliases.lua b/src/plugins/lua/aliases.lua index d1a3dcd9c6..ed665c2a48 100644 --- a/src/plugins/lua/aliases.lua +++ b/src/plugins/lua/aliases.lua @@ -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