From bc9edbf619b535b315389e625bdc00542ee1a646 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sun, 31 Jan 2021 10:40:30 -0500 Subject: [PATCH] test: reproduce large cdata parse failure from #2132 --- test/xml/sax/test_parser.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/xml/sax/test_parser.rb b/test/xml/sax/test_parser.rb index 328deb88f7..161ad0c625 100644 --- a/test/xml/sax/test_parser.rb +++ b/test/xml/sax/test_parser.rb @@ -388,6 +388,38 @@ def test_square_bracket_in_text # issue 1261 @parser.parse(xml) assert_includes(@parser.document.data, "en:#:home_page:#:stories:#:[6]:#:name") end + + def test_large_cdata_is_handled + # see #2132 and https://gitlab.gnome.org/GNOME/libxml2/-/issues/200 + skip("Upstream libxml2 <= 2.9.10 needs to be patched") if Nokogiri::VersionInfo.instance.libxml2_using_system? + + template = <<~EOF + + + + + gorilla + secret + + + + + + + + + EOF + + factor = 10 + huge_data = "a" * (1024 * 1024 * factor) + xml = StringIO.new(template % (huge_data)) + + handler = Nokogiri::SAX::TestCase::Doc.new + parser = Nokogiri::XML::SAX::Parser.new(handler) + parser.parse(xml) + + assert_predicate(handler.errors, :empty?) + end end end end