Index: src/OFString+JSONParsing.m ================================================================== --- src/OFString+JSONParsing.m +++ src/OFString+JSONParsing.m @@ -135,13 +135,10 @@ ret |= c + 10 - 'A'; else return 0xFFFF; } - if (ret == 0) - return 0xFFFF; - return ret; } static inline OFString * parseString(const char **pointer, const char *stop, size_t *line) Index: tests/OFJSONTests.m ================================================================== --- tests/OFJSONTests.m +++ tests/OFJSONTests.m @@ -27,11 +27,11 @@ OFDictionary *_dictionary; } @end static OFString *string = @"{\"f\\0oo\"\t:'b\\na\\r', \"x\":/*foo*/ [.5\r,0xF," - @"null//bar\n,\"foo\",false]}"; + @"null//bar\n,\"fo\\u0000o\",false]}"; @implementation OFJSONTests - (void)setUp { [super setUp]; @@ -40,11 +40,11 @@ @"f\0oo", @"b\na\r", @"x", [OFArray arrayWithObjects: [OFNumber numberWithFloat: .5f], [OFNumber numberWithInt: 0xF], [OFNull null], - @"foo", + @"fo\0o", [OFNumber numberWithBool: false], nil], nil]; } @@ -61,11 +61,12 @@ } - (void)testJSONRepresentation { OTAssert(_dictionary.JSONRepresentation, - @"{\"f\\u0000oo\":\"b\\na\\r\",\"x\":[0.5,15,null,\"foo\",false]}"); + @"{\"f\\u0000oo\":\"b\\na\\r\",\"x\":[0.5,15,null,\"fo\\u0000o\"," + @"false]}"); } - (void)testSortedJSONRepresentation { OTAssertEqualObjects( @@ -78,18 +79,18 @@ - (void)testPrettyJSONRepresentation { OTAssertEqualObjects([_dictionary JSONRepresentationWithOptions: OFJSONRepresentationOptionPretty], @"{\n\t\"f\\u0000oo\": \"b\\na\\r\",\n\t\"x\": [\n\t\t0.5,\n\t\t15," - @"\n\t\tnull,\n\t\t\"foo\",\n\t\tfalse\n\t]\n}"); + @"\n\t\tnull,\n\t\t\"fo\\u0000o\",\n\t\tfalse\n\t]\n}"); } - (void)testJSON5Representation { OTAssertEqualObjects([_dictionary JSONRepresentationWithOptions: OFJSONRepresentationOptionJSON5], - @"{\"f\\0oo\":\"b\\\na\\r\",x:[0.5,15,null,\"foo\",false]}"); + @"{\"f\\0oo\":\"b\\\na\\r\",x:[0.5,15,null,\"fo\\0o\",false]}"); } - (void)testObjectByParsingJSONFailsWithInvalidJSON { OTAssertThrowsSpecific([@"{" objectByParsingJSON],