diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb index d9a9641c20..46cd6f7dbd 100644 --- a/test/rexml/test_document.rb +++ b/test/rexml/test_document.rb @@ -42,8 +42,8 @@ EOF end class GeneralEntityTest < self - def test_have_value - xml = < @@ -59,21 +59,21 @@ EOF EOF - doc = REXML::Document.new(xml) - assert_raise(RuntimeError) do - doc.root.children.first.value + doc = REXML::Document.new(xml) + assert_raise(RuntimeError) do + doc.root.children.first.value + end + REXML::Security.entity_expansion_limit = 100 + assert_equal(100, REXML::Security.entity_expansion_limit) + doc = REXML::Document.new(xml) + assert_raise(RuntimeError) do + doc.root.children.first.value + end + assert_equal(101, doc.entity_expansion_count) end - REXML::Security.entity_expansion_limit = 100 - assert_equal(100, REXML::Security.entity_expansion_limit) - doc = REXML::Document.new(xml) - assert_raise(RuntimeError) do - doc.root.children.first.value - end - assert_equal(101, doc.entity_expansion_count) - end - def test_empty_value - xml = < @@ -89,21 +89,21 @@ EOF EOF - doc = REXML::Document.new(xml) - assert_raise(RuntimeError) do - doc.root.children.first.value + doc = REXML::Document.new(xml) + assert_raise(RuntimeError) do + doc.root.children.first.value + end + REXML::Security.entity_expansion_limit = 100 + assert_equal(100, REXML::Security.entity_expansion_limit) + doc = REXML::Document.new(xml) + assert_raise(RuntimeError) do + doc.root.children.first.value + end + assert_equal(101, doc.entity_expansion_count) end - REXML::Security.entity_expansion_limit = 100 - assert_equal(100, REXML::Security.entity_expansion_limit) - doc = REXML::Document.new(xml) - assert_raise(RuntimeError) do - doc.root.children.first.value - end - assert_equal(101, doc.entity_expansion_count) - end - def test_with_default_entity - xml = < @@ -116,20 +116,20 @@ EOF EOF - REXML::Security.entity_expansion_limit = 4 - doc = REXML::Document.new(xml) - assert_equal("\na\na a\n<\n", doc.root.children.first.value) - REXML::Security.entity_expansion_limit = 3 - doc = REXML::Document.new(xml) - assert_raise(RuntimeError) do - doc.root.children.first.value + REXML::Security.entity_expansion_limit = 4 + doc = REXML::Document.new(xml) + assert_equal("\na\na a\n<\n", doc.root.children.first.value) + REXML::Security.entity_expansion_limit = 3 + doc = REXML::Document.new(xml) + assert_raise(RuntimeError) do + doc.root.children.first.value + end end end - end class ParameterEntityTest < self - def test_have_value - xml = < @@ -143,18 +143,18 @@ EOF EOF - assert_raise(REXML::ParseException) do - REXML::Document.new(xml) + assert_raise(REXML::ParseException) do + REXML::Document.new(xml) + end + REXML::Security.entity_expansion_limit = 100 + assert_equal(100, REXML::Security.entity_expansion_limit) + assert_raise(REXML::ParseException) do + REXML::Document.new(xml) + end end - REXML::Security.entity_expansion_limit = 100 - assert_equal(100, REXML::Security.entity_expansion_limit) - assert_raise(REXML::ParseException) do - REXML::Document.new(xml) - end - end - def test_empty_value - xml = < @@ -168,17 +168,17 @@ EOF EOF - assert_raise(REXML::ParseException) do - REXML::Document.new(xml) - end - REXML::Security.entity_expansion_limit = 100 - assert_equal(100, REXML::Security.entity_expansion_limit) - assert_raise(REXML::ParseException) do - REXML::Document.new(xml) + assert_raise(REXML::ParseException) do + REXML::Document.new(xml) + end + REXML::Security.entity_expansion_limit = 100 + assert_equal(100, REXML::Security.entity_expansion_limit) + assert_raise(REXML::ParseException) do + REXML::Document.new(xml) + end end end end - end def test_tag_in_cdata_with_not_ascii_only_but_ascii8bit_encoding_source tag = "..."