NSURLComponents does not correctly handle parameters

Originator:Raubtiger
Number:rdar://24434533 Date Originated:01-Feb-2016 10:41 AM
Status:Open Resolved:
Product:iOS Product Version:Xcode 7.2
Classification:Serious Bug Reproducible:Always
 
Summary:
If a URL contains a path and parameters the separator between path and parameters (;) is escaped to %3B and thus the separation fails

Steps to Reproduce:
1. open the attached storyboard.
2. Not that the assert at the end fails because the initial and reassembled URLs are not equal


Expected Results:
initial and reassembled URLs are equal

Actual Results:
initial and reassembled URLs are not equal


Version:
Xcode 7.2

Notes:


Configuration:
Playground

------ contents of the playground. Copy and past it into your own ----

//: Playground - noun: a place where people can play

import UIKit

// example URL string from the NSURL class documentation.
let urlString = "https://johnny:p4ssw0rd@www.example.com:443/script.ext;param=value?query=value#ref"

// convert to an NSURL object
guard let initialURL = NSURL(string: urlString) else {
    preconditionFailure()
}

// disassemble into NSURLComponents
guard let components = NSURLComponents(URL: initialURL, resolvingAgainstBaseURL: true) else {
    preconditionFailure()
}

// reassemble back into an NSURL object
let reassembledURL = components.URL

// whoops! The two are not equal. (the ; separating path and parameters was converted into %3B)
assert(initialURL == reassembledURL)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!