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-21] Standardize NSURL / NSPathUtilities behavior #4208

Open
jtbandes opened this issue Dec 3, 2015 · 0 comments
Open

[SR-21] Standardize NSURL / NSPathUtilities behavior #4208

jtbandes opened this issue Dec 3, 2015 · 0 comments

Comments

@jtbandes
Copy link
Collaborator

jtbandes commented Dec 3, 2015

Previous ID SR-21
Radar rdar://problem/22424272
Original Reporter @jtbandes
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Improvement
Assignee @parkera
Priority Medium

md5: bcd1290e284ffe9fda05487cde2ea447

Issue Description:

The methods provided in NSPathUtilities / NSURLPathUtilities categories adhere mostly to RFC 1808.

NSURLComponents, on the other hand, uses the more-modern RFC 3986 behavior.

My view is that continuing to expose RFC 1808–style behavior is harmful to users. Results may be unexpected:

NSURL(string: "http://one/two;three/four")!.URLByAppendingPathComponent("five")
// This returns "http://one/two/five;three/four".

// Paths whose last component starts/ends with a dot (.) also have problems:
let url = NSURL(fileURLWithPath: "/path/to/.file")

// Expected: ???
// Actual: ""
let ext = url.pathExtension!

// Expected (based on pathExtension being ""): "/path/to/.file"
// Actual: "/path/to/"
url.URLByDeletingPathExtension!

// Expected: same as original URL
// Actual: "/path/to./"
url.URLByDeletingPathExtension!.URLByAppendingPathExtension(ext)

// <rdar://18421068>, only recently resolved in El Capitan, was a similar issue in NSURLComponents.

This has produced some problems in Apple system behavior (see <rdar://23241861>), let alone latent bugs in third-party code.

These sorts of things should be hard to get wrong, rather than easy. I think the Foundation APIs could use some love here.

@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