From 76bfda8f7291dc73b97fb6d3a0d6f8027169fb75 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Tue, 5 Jan 2021 21:54:00 -0500 Subject: [PATCH] Remove leading whitespace from the XML under test This test was originally written with the intention of asserting that a runtime error related to XXE will be raised by the parser. However, because initial whitespace is present before the doctype, XmlMini_NokogiriSAX::HashBuilder has been raising an unrelated error in this test. Related to #41015 --- Using Nokogiri v1.10.10, the error being raised without this change is: > XML declaration allowed only at the start of the document but with this change we see the expected exception from the libxml2 SAX parser: > Entity 'a' not defined Using Nokogiri v1.11.0, in which error handling is broken (see sparklemotion/nokogiri#2168), without this change we see an exception being raised by HashBuilder because `characters` is called before `start_element` and so the content hash isn't initialized (see The error being raised with this change is: > Parse stack not empty! which is not the error we want (because of sparklemotion/nokogiri#2168), but the test still passes. Using Nokogiri with the fix from sparklemotion/nokogiri#2169, the error being raised without this change is: > XML declaration allowed only at the start of the document but with this change will be: > Entity 'a' not defined and we're back to the expected behavior. --- activesupport/test/xml_mini/xml_mini_engine_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/test/xml_mini/xml_mini_engine_test.rb b/activesupport/test/xml_mini/xml_mini_engine_test.rb index a6f2086ae59c1..c795457e9b495 100644 --- a/activesupport/test/xml_mini/xml_mini_engine_test.rb +++ b/activesupport/test/xml_mini/xml_mini_engine_test.rb @@ -50,7 +50,7 @@ def test_file_from_xml def test_exception_thrown_on_expansion_attack assert_raise expansion_attack_error do - Hash.from_xml(<<-eoxml) + Hash.from_xml(<<~eoxml)