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() counts Unicode characters instead of UTF-8 octets for the local-part limit #573
email() checks len(username_part) > 64, which measures Unicode characters rather than UTF-8 octets. The validator accepts non-ASCII local parts, so a value can pass this check while exceeding SMTP's 64-octet limit.
Reproduced on master at 22786cc (validators 0.36.0, Python 3.14):
Expected: ValidationError, just as for a 65-character ASCII local part. The 32-character variant occupies exactly 64 UTF-8 octets and should continue to pass.
RFC 5321 section 4.5.3.1.1 specifies the local-part limit in octets, explicitly distinguishing it from character counts. This matters for callers validating internationalized addresses before storing or using them: values over that limit currently pass the input check.
The fix can be limited to measuring the UTF-8-encoded local part. Domain handling and the existing accepted character set need no change. I have verified regression cases for 64-byte ASCII, 64-byte Unicode, and mixed ASCII/Unicode local parts at and above the boundary.
Codex assisted with reproducing this behavior and preparing the fix and tests. The example above was executed locally.
Activity