Skip to content

Revert strict IPv6 validation in URL #1258

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

Merged
merged 1 commit into from
Apr 23, 2025

Conversation

jrflat
Copy link
Contributor

@jrflat jrflat commented Apr 21, 2025

Previously, URL and the URLParser mistakenly allowed invalid characters in an IP-literal (within the square brackets) if the zone-ID was percent-encoded. This was revealed by testing the NSURL and CFURL 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 like http://[www.apple.com] were allowed.

While I think better IPv6 validation would ultimately be good, it could impact bincompat for URL, URLComponents, and NSURL (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.

@jrflat
Copy link
Contributor Author

jrflat commented Apr 21, 2025

@swift-ci please test

@jrflat jrflat merged commit a842db4 into swiftlang:main Apr 23, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants