Repository navigation
fix: Validate the uri, uri-reference and email formats as defined by RFC 3986 and RFC 5321 (email no longer accepts non-ASCII local parts) - #1005
Conversation
bf48b32 to
62da2b9
Compare
DannyvdSluijs
left a comment
There was a problem hiding this comment.
Approved but I believe a small cleanup can be done to avoid duplicate checks as flagged by an agent review.
0887c84 to
d60d16d
Compare
|
Another AI agent review of this PR found some more possible issues. I'll fix them before this gets merged, so please hold off on merging for now. Important
Minor
One more point that is a behaviour change rather than a bug: |
d60d16d to
b37bb28
Compare
|
All six findings from my previous comment are fixed in b37bb28:
I checked Some existing test cases expected stricter behaviour than RFC 3986 allows, so they are now valid: About the CHANGELOG: it is generated from the PR title, so I put the behaviour change in the title instead of editing the CHANGELOG by hand. Feel free to add the I also re-signed the commits after the rebase. |
|
@Roman3349 #1010 was just merged. This fixes the running of the test suite as upstream was refactored into a new file and json structure. Could you rebase this and any other PR's to ensure there is no regression with the PR's comparing against the official test suite? |
…RFC 3986 and RFC 5321 Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
… address literals Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
b37bb28 to
b5a2c2a
Compare
|
Thanks! I rebased this PR and my other open PRs onto The rebase surfaced a few things:
I did not rebase #993, because it targets the branch of #926 rather than |
Description
The
uri,uri-referenceandemailformats accepted values that are not valid, and rejected some that are.UriValidatorandRelativeReferenceValidatorchecked URIs with patterns that only roughly follow RFC 3986:$instead of\z.http://example.com/%,http://example.com/%6G) passed in a URI.[,"or non-ASCII characters, more than one@, and a non-numeric port.http://[::ffff:01.2.3.4]) passed.1:b) passed, while the network-path reference//with an empty authority was rejected.The
emailformat usedfilter_var()withFILTER_FLAG_EMAIL_UNICODE, which accepts non-ASCII characters in the local part (aé@iana.org), but rejects quoted local parts with a space ("joe bloggs"@example.com," "@iana.org), single-label domains (test@io) and domains that look like an IPv4 address (test@255.255.255.255).Changes:
Tool\Validator\Rfc3986: new, matches the URI and URI-reference grammar of RFC 3986, section 3 and 4.1. An IP literal is checked withfilter_var().UriValidator,RelativeReferenceValidator: check the RFC 3986 grammar first, and then their existing rules, so the stricter rules they already had (for example formailto:URIs, or rejecting///) are kept.RelativeReferenceValidatorno longer rejects//.Tool\Validator\EmailValidator: new, validates an address as the Mailbox of RFC 5321, section 4.1.2: a dot-string or quoted-string local part of at most 64 octets, and a domain or an IPv4/IPv6 address literal. It is ASCII only, internationalized addresses are covered byidn-email.FormatConstraint(non-strict mode) and the Draft-06, Draft-07 and Draft 2019-09FormatConstraints: useEmailValidatorforemail.JsonSchemaTestSuiteTest: removes the 68 skippedoptional/format/uri.json,uri-reference.jsonandemail.jsoncases, which all pass now, together with their comments and the comment of the optional anchor section, which is already empty onmain.Related Issue
None
Type of Change
Checklist
Additional Notes
info@somewherewas an invalidemailinFormatConstraintTest. It is valid now, as the test suite expects a single-label domain to be valid (test@io).#1002 (Draft-04 in strict mode) and #971 (Draft 2020-12) include this commit and apply it to their
FormatConstraints as well.