Skip to content

Restore URL.host bracket stripping for compatibility #1008

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
Oct 25, 2024

Conversation

jrflat
Copy link
Contributor

@jrflat jrflat commented Oct 25, 2024

As part of the new Swift URL implementation, we unified URL.host to behave like URLComponents.host, which will return an IP literal with the square brackets included. While RFC 3986 does say that host includes these square brackets, this change caused bincompat issues for clients who take IPv6 addresses from URL.host and pass them directly to APIs like inet_pton(3).

Because URL.host has long behaved by stripping the brackets, and no longer stripping them can cause immediate client breakage that requires workaround, this PR restores the previous behavior. Thank you to all who worked around it for the time being.

Resolves #957

@jrflat
Copy link
Contributor Author

jrflat commented Oct 25, 2024

@swift-ci please test

@jrflat jrflat requested review from parkera and jmschonfeld October 25, 2024 19:37
@parkera
Copy link
Contributor

parkera commented Oct 25, 2024

Should cherry pick for release/6.0

@jrflat jrflat merged commit d14ef7e into swiftlang:main Oct 25, 2024
3 checks passed
jrflat added a commit to jrflat/swift-foundation that referenced this pull request Oct 29, 2024
cthielen pushed a commit to cthielen/swift-foundation that referenced this pull request Nov 8, 2024
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.

URL.init(string:) handling of IPv6 addresses has changed in Swift 6
2 participants