Control characters are not unescaped
Closed this issue · 3 comments
IngmarStein commented
Currently, json-swift only handles escaped quote characters, but according to ECMA-404 (json.org), there are other control sequences which need to be unescaped while parsing strings, i.e. ", , /, \b, \f, \n, \r, \t and \u.
The following test fails with the current HEAD:
func testParseStringWithEscapedControlCharacters() {
let string = "\"\\\\\\/\\n\\r\\t\""
let jsvalue = JSValue.parse(string)
XCTAssertTrue(jsvalue.error == nil, jsvalue.error?.userInfo?.description ?? "No error info")
XCTAssertEqual(jsvalue.value!.string!, "\\/\n\r\t")
}
owensd commented
Hmm... good catch. I'll look into it.
owensd commented
Should be fixed now. Please re-open if you see any other issues with this.
IngmarStein commented
That was quick, thanks!