summaryrefslogtreecommitdiff
path: root/test/json/json_parser_test.rb
diff options
context:
space:
mode:
authortompng <[email protected]>2025-01-20 20:42:20 +0900
committerJean Boussier <[email protected]>2025-01-20 14:20:55 +0100
commitc026e44bb557dc42516785beba00452fa462738e (patch)
tree2842d554976bc9c7489c6f7083c3d17a277498cf /test/json/json_parser_test.rb
parent2b4b7bdb10dc8671bbc9e757f05bb74355891062 (diff)
[ruby/json] Fix parsing incomplete unicode escape "\uaaa"
https://github.com/ruby/json/commit/86c0d4eb7e
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12602
Diffstat (limited to 'test/json/json_parser_test.rb')
-rw-r--r--test/json/json_parser_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/json/json_parser_test.rb b/test/json/json_parser_test.rb
index c5ce02320f..bca8ff287c 100644
--- a/test/json/json_parser_test.rb
+++ b/test/json/json_parser_test.rb
@@ -302,6 +302,14 @@ class JSONParserTest < Test::Unit::TestCase
end
end
+ def test_invalid_unicode_escape
+ assert_raise(JSON::ParserError) { parse('"\u"') }
+ assert_raise(JSON::ParserError) { parse('"\ua"') }
+ assert_raise(JSON::ParserError) { parse('"\uaa"') }
+ assert_raise(JSON::ParserError) { parse('"\uaaa"') }
+ assert_equal "\uaaaa", parse('"\uaaaa"')
+ end
+
def test_parse_big_integers
json1 = JSON(orig = (1 << 31) - 1)
assert_equal orig, parse(json1)