Skip to content
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

[SR-15632] URL: Strange results with hostnames in square brackets #3185

Open
karwa opened this issue Dec 21, 2021 · 0 comments
Open

[SR-15632] URL: Strange results with hostnames in square brackets #3185

karwa opened this issue Dec 21, 2021 · 0 comments

Comments

@karwa
Copy link
Contributor

karwa commented Dec 21, 2021

Previous ID SR-15632
Radar None
Original Reporter @karwa
Type Bug
Environment

Swift 5.5.2, Xcode 13.2, macOS 11.6

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: fc6db48c2ef78af80ca1f0400354939b

Issue Description:

var url = URL(string: "http://[:errwhat/hello")!
print(url.host!) // "[:errwhat"

url = URL(string: "http://[:]errwhat/hello")!
print(url.host!) // ":]errwha"

url = URL(string: "http://errr[:]what/hello")!
print(url.host!) // "rrr[:]wha"

What I suspect is happening is some astonishingly lazy IPv6 parsing - It detects that the hostname contains an opening square bracket, followed a closing square bracket, and so the host should be trimmed of its first and last characters. It doesn't actually check that the opening square bracket is the first character of the hostname, or that the closing square bracket is the last character of the hostname, or that a valid IPv6 address is contained within them.

These URLs should all fail to parse.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant