From 5c501bcbdb163f8e27d098e2149cf9840e1043ac Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Mon, 18 Sep 2023 09:54:23 -0500 Subject: [ruby/psych] Add test for code_point_limit Only supported on JRuby currently. https://github.com/ruby/psych/commit/0c1754eefe --- test/psych/test_parser.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/psych/test_parser.rb b/test/psych/test_parser.rb index 3b67a8eab1..c1e0abb89d 100644 --- a/test/psych/test_parser.rb +++ b/test/psych/test_parser.rb @@ -384,6 +384,25 @@ module Psych [:end_stream, [2, 0, 2, 0]]], events end + if Psych::Parser.method_defined?(:code_point_limit) + def test_code_point_limit + yaml = "foo: bar\n" * 500_000 + assert_raise(org.snakeyaml.engine.v2.exceptions.YamlEngineException) do + Psych.load(yaml) + end + + assert_nothing_raised do + begin + old_code_point_limit, Psych::Parser.code_point_limit = Psych::Parser::code_point_limit, 5_000_000 + + Psych.load(yaml) + ensure + Psych::Parser.code_point_limit = old_code_point_limit + end + end + end + end + def assert_called call, with = nil, parser = @parser if with call = parser.handler.calls.find { |x| -- cgit v1.2.3