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-13993] NSString.appendingPathComponent yields wrong result on Linux #3238

Open
Bouke opened this issue Dec 26, 2020 · 1 comment
Open

Comments

@Bouke
Copy link
Contributor

Bouke commented Dec 26, 2020

Previous ID SR-13993
Radar rdar://problem/72864715
Original Reporter @Bouke
Type Bug
Environment

I've tested on macOS with Swift 5.2.4 and Linux with Swift 5.1.5. A unit test targeting using this API targeting Swift 5.3 is failing, so I suppose the bug is still present in the latest release version.

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: 185106875901dcf51950c3b21e45f49e

Issue Description:

The following code yields different output on macOS (Foundation) vs Linux (SwiftFoundation):

NSString(string: "./").appendingPathComponent("/foo")

The output on macOS is: "./foo"
The output on Linux is: ".//foo"

Additional test script:

import Foundation
let a = NSString(string: "")
print(a.appendingPathComponent("foo"))
print(a.appendingPathComponent("/foo"))
print(a.appendingPathComponent("//foo"))
let b = NSString(string: "./")
print(b.appendingPathComponent("foo"))
print(b.appendingPathComponent("/foo"))
print(b.appendingPathComponent("//foo"))

Output on macOS:

foo
/foo
/foo
./foo
./foo
./foo

Output on Linux:

foo
/foo
//foo
./foo
.//foo
.///foo

The following is related: #5582.

@typesanitizer
Copy link

@swift-ci create

@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

2 participants