Fix #424: Escape question mark '?'
It would otherwise be interpreted as the beginning of the query part in an URL.
This commit is contained in:
parent
17ce107129
commit
eba4df2f51
2 changed files with 3 additions and 3 deletions
|
|
@ -12,7 +12,7 @@ public extension String {
|
|||
}
|
||||
|
||||
func stringByAddingPercentEncodingForRFC3986() -> String? {
|
||||
let unreserved = "-._~/?"
|
||||
let unreserved = "-._~/"
|
||||
var allowed = CharacterSet.alphanumerics
|
||||
allowed.insert(charactersIn: unreserved)
|
||||
return addingPercentEncoding(withAllowedCharacters: allowed)
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ class StringUtilitiesTest: XCTestCase {
|
|||
|
||||
func testStringByAddingPercentEncodingForRFC3986() {
|
||||
[
|
||||
("!#$&'()*+,/:;=?@[]^", "%21%23%24%26%27%28%29%2A%2B%2C/%3A%3B%3D?%40%5B%5D%5E"),
|
||||
("-._~/?", "-._~/?"),
|
||||
("!#$&'()*+,/:;=?@[]^", "%21%23%24%26%27%28%29%2A%2B%2C/%3A%3B%3D%3F%40%5B%5D%5E"),
|
||||
("-._~/", "-._~/"),
|
||||
("A*b!c", "A%2Ab%21c"),
|
||||
].forEach { unencoded, encoded in
|
||||
XCTAssertEqual(unencoded.stringByAddingPercentEncodingForRFC3986(), encoded)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue