MAS-WP-0005-T02: SCP-1 quoted local-parts equivalent on receipt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 252470@bnt-lap001 Assistant-Session: ad628c8f-4be2-4979-94c9-76c7ed6f8241
This commit is contained in:
parent
5b57a9941e
commit
0a2d811444
9 changed files with 70 additions and 6 deletions
|
|
@ -141,6 +141,25 @@ def parse_address(value: str) -> ParsedAddress:
|
|||
return ParsedAddress(local=parse_local_part(local), domain=domain)
|
||||
|
||||
|
||||
def unquote_local_part(local: str) -> str:
|
||||
"""Drop quotes a receiver cannot distinguish (v0.1.1, SCP-1).
|
||||
|
||||
`"ticket=PR42"` is not canonical, but RFC 5321 treats it as equivalent to
|
||||
`ticket=PR42` and MTAs strip such quotes, so receivers must too. Quoted
|
||||
content with quoted-pairs or inner quotes is left alone and stays
|
||||
non-canonical.
|
||||
"""
|
||||
if len(local) >= 2 and local[0] == local[-1] == '"' and not any(c in '"\\' for c in local[1:-1]):
|
||||
return local[1:-1]
|
||||
return local
|
||||
|
||||
|
||||
def parse_received_address(value: str) -> ParsedAddress:
|
||||
"""Parse a recipient as a receiver sees it: unnecessary quotes removed."""
|
||||
local, domain = split_address(value)
|
||||
return ParsedAddress(local=parse_local_part(unquote_local_part(local)), domain=domain)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ValidationResult:
|
||||
ok: bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue