Repository navigation
fix(email): accept exactly one pair of brackets around address literals - #586
Open
yuchengshen931122-creator wants to merge 1 commit into
Conversation
`lstrip("[")`/`rstrip("]")` removed any number of brackets, so
`user@[[192.168.0.1]]` and even `user@[[192.168.0.1]` were valid with
`ipv4_address=True`. RFC 5321 4.1.3 allows exactly one pair.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #583.
What
emailunwrapped address literals withdomain_part.lstrip("[").rstrip("]"), which removes any number of brackets, souser@[[192.168.0.1]]and the unbalanceduser@[[192.168.0.1]were valid withipv4_address=True. RFC 5321 §4.1.3 allows exactly one pair. The literal is now unwrapped withdomain_part[1:-1]; anything left over makes the IP check fail.Tests
test_rejects_extra_brackets_around_address_literal(4 cases, IPv4 and IPv6) – fails on master, passes with this change; it also checks that a single pair is still accepted.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