Skip to content

Accept at-signs inside quoted email local parts - #515

Open
prnvh wants to merge 1 commit into
python-validators:masterfrom
prnvh:fix/quoted-email-at-signs
Open

prnvh wants to merge 1 commit into
python-validators:masterfrom
prnvh:fix/quoted-email-at-signs

Conversation

@prnvh

@prnvh prnvh commented Oct 15, 2026

Copy link
Copy Markdown

The email validator rejects valid quoted local parts containing @, such as "test@test"@example.com, because its early guard requires exactly one at-sign in the entire address.

RFC 5321 section 4.1.2 permits @ inside a quoted local part. The function already splits at the final at-sign and validates the complete local part and domain separately, so the guard only needs to require that a separator is present.

This change:

  • Allows at-signs inside quoted local parts, including multiple at-signs.
  • Moves the existing "test@test"@example.com fixture from invalid to valid cases.
  • Adds regression tests for quoted at-signs and malformed addresses, including unquoted extra separators, unmatched quotes, missing domains and invalid domains.

Standard reference: https://www.rfc-editor.org/rfc/rfc5321#section-4.1.2

Validation on Python 3.12.14:

  • Before the fix, the email regression suite has four failures and 40 passes.
  • With the fix, pytest . -q: 1,182 passed.
  • tox -e py312: passed, including a fresh source-distribution build and 1,182 tests.
  • ruff check . and ruff format --check .: passed.
  • pyright --pythonpath .venv/Scripts/python.exe .: zero errors or warnings.
  • bandit -c pyproject.toml -r src/validators: no issues identified.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant