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-3216] String.addingPercentEncoding() mishandles Unicode characters #4500

Closed
swift-ci opened this issue Nov 16, 2016 · 3 comments
Closed

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-3216
Radar None
Original Reporter collinhundley (JIRA User)
Type Bug
Status Resolved
Resolution Cannot Reproduce
Additional Detail from JIRA
Votes 2
Component/s Foundation
Labels Bug, Linux
Assignee None
Priority Medium

md5: 2ce68f79cd1be82026c5ff96042bcc1f

Issue Description:

`String.addingPercentEncoding(withAllowedCharacters: CharacterSet)` produces incorrect output when the string contains certain Unicode characters. It does not seem to matter which CharacterSet is used.

This issue occurs on Ubuntu 16.04, but does NOT occur on macOS.
Tested on Swift 3.0.1 Release and swift-DEVELOPMENT-SNAPSHOT-2016-11-12-a-ubuntu16.04.

Steps to reproduce:

```swift
import Foundation
let str = "CaféRio" // Accented "e"
let escaped = str.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)!
print(escaped)
```
Expected output: Caf%C3%A9Rio
Actual output: Caf%C3%A9Ri

Notice that the actual Unicode character is escaped correctly, but the resulting string is missing a character at the end. For each "é" inside the string, another trailing character goes missing.

@swift-ci
Copy link
Contributor Author

Comment by Sergey Minakov (JIRA)

This issue could have been fixed in #706
While I get expected result (Caf%C3%A9Rio) with this fix, reverting the fix, gives me incorrect result (Caf%C3%A9Ri) for 'CaféRio'.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed).
But I'm not sure if this changes was included in snapshot.

@swift-ci
Copy link
Contributor Author

Comment by sai Hema k (JIRA)

collinhundley (JIRA User) Look like the issue is resolved now .I have tested with latest snapshot swift-DEVELOPMENT-SNAPSHOT-2017-03-09-a-ubuntu16.04 and swift-3.1-DEVELOPMENT-SNAPSHOT-2017-02-19-a-ubuntu16.04.Please verify and close the issue

@swift-ci
Copy link
Contributor Author

Comment by Matt Rajca (JIRA)

Looks fixed in Swift 4.0.3 on Linux.

@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
This issue was closed.
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