Skip to content

Commit

Permalink
Fix site: queries escaping with iOS 17 SDK (#640)
Browse files Browse the repository at this point in the history
After moving to Xcode 15 the following change in URL parsing had effect:
https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes
Fixed: For apps linked on or after iOS 17 and aligned OS versions, URL parsing has updated from the obsolete RFC 1738/1808 parsing to the same RFC 3986 parsing as URLComponents. This unifies the parsing behaviors of the URLand URLComponents APIs. Now, URL automatically percent- or IDNA-encodes invalid characters to help create a valid URL.
  • Loading branch information
dus7 authored Jan 29, 2024
1 parent 5af8fbc commit 055cc2d
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions Sources/Common/Extensions/URLExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,21 +158,16 @@ extension URL {
s = scheme.separated() + s.dropFirst(scheme.separated().count - 1)
}

#if os(macOS)
let url: URL?
let urlWithScheme: URL?
if #available(macOS 14.0, *) {
if #available(macOS 14.0, iOS 17.0, *) {
// Making sure string is strictly valid according to the RFC
url = URL(string: s, encodingInvalidCharacters: false)
urlWithScheme = URL(string: NavigationalScheme.http.separated() + s, encodingInvalidCharacters: false)
} else {
url = URL(string: s)
urlWithScheme = URL(string: NavigationalScheme.http.separated() + s)
}
#else
let url = URL(string: s)
let urlWithScheme = URL(string: NavigationalScheme.http.separated() + s)
#endif

if let url {
// if URL has domain:port or user:password@domain mistakengly interpreted as a scheme
Expand Down

0 comments on commit 055cc2d

Please sign in to comment.