Skip to content

URL Parsing behaviour changed on Linux between 5.10 and 6.0 #863

Closed
@Lukasa

Description

@Lukasa

When attempting to parse the string "ftp://user:password@*.xn--poema-9qae5a.com.br:4343/cat.txt" as a URL, the result is different between 5.10 and 6.0 on Linux, and on Apple platforms as well. The difference is at the very least in the host component.

This can be shown by using the following test program:

import Foundation

func main() {
    let x = URL(string: "ftp://user:password@*.xn--poema-9qae5a.com.br:4343/cat.txt")!
    print(x.host!)
}

main()
  • On Linux, Swift 5.10 (Swift version 5.10.1 (swift-5.10.1-RELEASE)), the result of this program is *.xn--poema-9qae5a.com.br.
  • On Linux, Swift 6.0 (Swift version 6.0-dev (LLVM 3751470251df3e4, Swift 026ffddec66fd08)), the result of the program is *.p%C3%A3oema%C3%A7%C3%A3.com.br.
  • On the latest macOS Sequoia 15.1 beta, the result is *.xn--poema-9qae5a.com.br.

Note that on Linux, 6.0, the URL type seems to have decided to thoroughly mangle the hostname. Specifically, it appears to have decoded the IDNA-encoded hostname, and then percent-encoded it when we got it back out. That can't possibly be the right thing to do.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions