You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
email: address literals with extra brackets are accepted (user@[[192.168.0.1]]) #583
With ipv4_address=True or ipv6_address=True, email unwraps the domain part with domain_part.lstrip("[").rstrip("]"). lstrip/rstrip remove every leading [ and trailing ], so any number of brackets is accepted on either side, even unbalanced ones.
RFC 5321 §4.1.3: address-literal = "[" ( IPv4-address-literal / IPv6-address-literal / General-address-literal ) "]" – exactly one pair of brackets. All three values above are invalid.
Proposed fix
Remove exactly one bracket on each side (domain_part[1:-1]); the inner value then fails the IP check because it still contains a bracket. A PR follows.
Found while writing specification-based tests for a university software-testing project (NYCU). The investigation and this write-up were done with the help of an AI assistant (Claude Code); the reproduction was run on the current master.
Activity
yuchengshen931122-creator commented on Nov 24, 2026
Closing: #535 (opened on 22 October) already fixes this, for email() and for hostname().
One correction to the text above. The suggested fix says that after removing one bracket on each side "the inner value then fails the IP check because it still contains a bracket". That is not true for user@[2001:db8::1%]]: the inner value is 2001:db8::1%], which is accepted as an address with the zone identifier ]. #535 checks for this explicitly; our pull request #586 did not and is closed.
Sorry for the duplicate. (Prepared with the help of an AI assistant.)
Activity
yuchengshen931122-creator commentedon Nov 24, 2026
Closing: #535 (opened on 22 October) already fixes this, for
email()and forhostname().One correction to the text above. The suggested fix says that after removing one bracket on each side "the inner value then fails the IP check because it still contains a bracket". That is not true for
user@[2001:db8::1%]]: the inner value is2001:db8::1%], which is accepted as an address with the zone identifier]. #535 checks for this explicitly; our pull request #586 did not and is closed.Sorry for the duplicate. (Prepared with the help of an AI assistant.)