-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quoted local parts fail validation; reserved R-LDH labels (double dashes) fail validation #92
Comments
See also #77 |
This is covered in the README. Obsolete forms of email addresses are rejected because they are likely to cause trouble in most situations that the library is intended for. |
Following up on issue pydantic/pydantic#4910, an email address produced by Hypothesis’ emails() strategy also fails to validate: |
Hypothesis is (probably?) wrong. RFC 5890 says:
("LDH labels" are defined as parts of a hostname between dots (in this case I understand this paragraph to mean that the pattern "??--" other than "xn--" (which is for IDNA) is reserved for future use and should be rejected today as invalid by applications that handle internationalized domains according to this RFC, which this library does. This is the opinion of the developer of the Python IDNA library at kjd/idna#27 who knows more about this than I do, so I'm really just going with what he says there. |
Hmm… tagging @Zac-HD and @DRMacIver from Hypothesis to chime in. |
Thanks for the ping! Reading RFC-5890 indicates that I'll ship a bugfix to exclude such invalid domain labels shortly, and really appreciate the report 😍 |
…n checks Including invalid RFC 5890 R-LDH labels (e.g. '??--' other than 'xn--'), see #92. The IDNA library will check this but its error messages are not friendly, and for future proofing it's better to not assume it does any general syntax checks.
…ith better exception messages People have opened issues several times about quoted local parts being incorrectly rejected. We can give a better error when it happens to head-off questions about it by parsing them so that we know when they occur. * Detect when a quoted-string local part might be present when splitting the address into a local part and domain part when the address has quoted @-signs in the local part rather than giving an error message about multiple @-signs. * Remove the surrounding quotes and un-escape the string before checking the syntax of the local part. Return the un-quoted and un-escaped string as the normalized local_part in the returned ValidatedEmail object if it's valid as an unquoted local part. * Check for invalid characters in the quoted-string (per the spec and our additional Unicode character checks) and raise exceptions. * Add a new option to accept quoted-string local parts which is off by default. When accepting them, apply Unicode normalization as per dot-atom internationalized addresses and apply minimal backslash escaping. * Update tests. See #54, #92.
…ith better exception messages People have opened issues several times about quoted local parts being incorrectly rejected. We can give a better error when it happens to head-off questions about it by parsing them so that we know when they occur. * Detect when a quoted-string local part might be present when splitting the address into a local part and domain part when the address has quoted @-signs in the local part rather than giving an error message about multiple @-signs. * Remove the surrounding quotes and un-escape the string before checking the syntax of the local part. Return the un-quoted and un-escaped string as the normalized local_part in the returned ValidatedEmail object if it's valid as an unquoted local part. * Check for invalid characters in the quoted-string (per the spec and our additional Unicode character checks) and raise exceptions. * Add a new option to accept quoted-string local parts which is off by default. When accepting them, apply Unicode normalization as per dot-atom internationalized addresses and apply minimal backslash escaping. * Update tests. See #54, #92.
Just taking the valid example from Wikipedia shows errors:
https://en.wikipedia.org/wiki/Email_address#Examples
The text was updated successfully, but these errors were encountered: