diff --git a/java/src/json/ext/StringDecoder.java b/java/src/json/ext/StringDecoder.java index e35638a4..362a0d68 100644 --- a/java/src/json/ext/StringDecoder.java +++ b/java/src/json/ext/StringDecoder.java @@ -155,7 +155,7 @@ private void handleEscapeSequence(ThreadContext context) throws IOException { break; default: if (allowInvalidEscape) { - append(character); + writeUtf8Char(character); } else { throw invalidEscape(context); } diff --git a/test/json/json_parser_test.rb b/test/json/json_parser_test.rb index 2fd7e274..025bf671 100644 --- a/test/json/json_parser_test.rb +++ b/test/json/json_parser_test.rb @@ -223,6 +223,12 @@ def test_parse_invalid_escape assert_equal "foo", parse(%("fo\\o"), allow_invalid_escape: true) end + def test_parse_invalid_escape_non_ascii + assert_equal "caf\u00e9", parse(%("caf\\\u00e9"), allow_invalid_escape: true) + assert_equal "\u3042", parse(%("\\\u3042"), allow_invalid_escape: true) + assert_equal "\u{1F600}", parse(%("\\\u{1F600}"), allow_invalid_escape: true) + end + def test_parse_arrays assert_equal([1,2,3], parse('[1,2,3]')) assert_equal([1.2,2,3], parse('[1.2,2,3]'))