Skip to content

URL.host should not return percent-encoded host #875

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
Aug 21, 2024

Conversation

jrflat
Copy link
Contributor

@jrflat jrflat commented Aug 19, 2024

Before this change, URL.host would just call .host(), which defaults to .host(percentEncoded: true). This meant that if the host was IDNA-encoded, .host would decode the IDNA-encoding and then percent-encode, returning the percent-encoded string.

This PR fixes .host to match the behavior before the Swift URL implementation:

  • If the host was percent-encoded, return the percent-decoded host
  • If the host was IDNA-encoded (or not encoded at all), return that host string

This is exactly the behavior of .host(percentEncoded: false), which is now used instead of .host().

Resolves #863 (thanks @Lukasa!)

@jrflat
Copy link
Contributor Author

jrflat commented Aug 19, 2024

@swift-ci please test

@Lukasa
Copy link
Contributor

Lukasa commented Aug 20, 2024

No, thank you @jrflat! 🎉

@jrflat jrflat force-pushed the url-host-no-encoding branch from fb88623 to da61158 Compare August 20, 2024 15:06
@jrflat
Copy link
Contributor Author

jrflat commented Aug 20, 2024

Fixed conflicts
@swift-ci please test

@jrflat
Copy link
Contributor Author

jrflat commented Aug 20, 2024

@swift-ci please test

@jrflat jrflat requested review from parkera and jmschonfeld August 21, 2024 22:49
@jrflat jrflat merged commit 2966e02 into swiftlang:main Aug 21, 2024
3 checks passed
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 Parsing behaviour changed on Linux between 5.10 and 6.0
4 participants