Revert strict IPv6 validation in URL #1258
Merged
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.
Previously,
URL
and theURLParser
mistakenly allowed invalid characters in an IP-literal (within the square brackets) if the zone-ID was percent-encoded. This was revealed by testing theNSURL
andCFURL
re-core in Swift. My original goal was to make the new implementation match the slightly more strict validation of the old NS/CFURL implementations for compatibility.However, I misunderstood which characters
CFURL
was actually allowing when validating an IP-literal. Instead of validating hex digits, colons, and periods before a potential zone ID, it was allowing any valid ASCII character anywhere in the host, so malformed URLs likehttp://[www.apple.com]
were allowed.While I think better IPv6 validation would ultimately be good, it could impact bincompat for
URL
,URLComponents
, andNSURL
(using the Swift parser) in rare cases when a client passes an invalid IPv6 string. This PR keeps the proper compatibility fix while reverting the stricter IPv6 validation code, which we could revisit at a later time.