Skip to content

fix(email, url): accept quoted pairs with any visible character again - #585

Open
yuchengshen931122-creator wants to merge 1 commit into
python-validators:masterfrom
yuchengshen931122-creator:g33/fix-quoted-pair
Open

yuchengshen931122-creator wants to merge 1 commit into
python-validators:masterfrom
yuchengshen931122-creator:g33/fix-quoted-pair

Conversation

@yuchengshen931122-creator

Copy link
Copy Markdown

Fixes #582.

What

af69a68 changed the quoted-pair class in the local-part regex from \\[\001-\011\013\014\016-\177] to \\[\011.]. Inside [...] the . is a literal dot, so only backslash-TAB and backslash-dot were accepted and "a\"b"@example.com was rejected. This restores the previous class (the one Django uses) in email.py and in url.py (_username_regex, same change in the same commit).

Behaviour

  • "a\"b", "a\\b", "\a", "a\ b" as local parts: now valid (RFC 5322 §3.2.1, quoted-pair = "\" (VCHAR / WSP)).
  • Existing expectations are unchanged: "\<TAB>" stays valid, "\<LF>" and "\<CR>" stay invalid (test_returns_failed_validation_on_invalid_email).

Tests

  • New: test_accepts_quoted_pair_with_any_visible_character (4 cases) – fails on master, passes with this change.
  • Checked locally with the CI commands: uv run pytest . (1,578 passed), ruff format ., ruff check ., pyright . (0 errors).

Found while writing specification-based tests for a university software-testing project (NYCU). The change and this description were prepared with the help of an AI assistant (Claude Code).

🤖 Generated with Claude Code

af69a68 changed the quoted-pair class from `\[\001-\011\013\014\016-\177]`
to `\[\011.]`. Inside a character class `.` is a literal dot, so only
backslash-TAB and backslash-dot were accepted and `"a\\"b"@example.com` was
rejected. Restore the previous class (the one Django uses); escaped LF/CR
stay invalid, so existing expectations are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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.

email: quoted pairs only accept \<TAB> and \. since af69a68, so "a\"b"@example.com is rejected

1 participant