gh-101034: Clarify error for email domain ending with a dot#151972
Open
tonghuaroot wants to merge 1 commit into
Open
gh-101034: Clarify error for email domain ending with a dot#151972tonghuaroot wants to merge 1 commit into
tonghuaroot wants to merge 1 commit into
Conversation
get_domain's obs-domain loop called get_atom on an empty string after a trailing dot, surfacing the internal "expected atext but found ''" instead of a meaningful message. Raise a clear HeaderParseError instead. A trailing-dot domain remains invalid per the RFC 5322 dot-atom and obs-domain grammars; only the diagnostic changes.
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.
email.headerregistry.Address(addr_spec="user@example.org.")(a domain endingin a dot) raises a cryptic
HeaderParseError: expected atext but found ''thatgives no hint about the trailing dot.
Per RFC 5322 the rejection is correct --
dot-atom/obs-domainboth requirean atom after every
., so a trailing-dot domain isn't a validaddr-specdomain. The only defect is the message: in
_header_value_parser.get_domain,the obs-domain fallback reaches the final
.and callsget_atom(''), whichsurfaces that bare internal error.
This raises a clear
HeaderParseError("expected atom after '.' but found end of domain")instead. Behavior is unchanged (the trailing-dot domain is stillrejected); only the diagnostic improves -- the "more informative error"
requested in the issue.
If
emailshould instead accept the FQDN-root trailing dot, that is abehavior change that deserves its own issue and need not block this diagnostic
fix.
Issue: #101034