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:
Danny Moesch 2020-11-07 13:30:38 +01:00 committed by Mingshen Sun
parent 17ce107129
commit eba4df2f51
2 changed files with 3 additions and 3 deletions

View file

@ -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)