From bb1d005da6115d3175d6a24bb16b93e02e3a1f51 Mon Sep 17 00:00:00 2001 From: shugo Date: Mon, 1 Sep 2008 13:41:38 +0000 Subject: * lib/rexml/document.rb: limit entity expansion. * lib/rexml/entity.rb: ditto. * test/rexml/test_document.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rexml/test_document.rb | 83 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 test/rexml/test_document.rb (limited to 'test/rexml/test_document.rb') diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb new file mode 100644 index 0000000000..9e9e58b7a0 --- /dev/null +++ b/test/rexml/test_document.rb @@ -0,0 +1,83 @@ +require "rexml/document" +require "test/unit" + +class REXML::TestDocument < Test::Unit::TestCase + def test_new + doc = REXML::Document.new(< +Hello world! +EOF + assert_equal("Hello world!", doc.root.children.first.value) + end + + def test_entity_expansion_limit + xml = < + + + + + + + +]> + +&a; + +EOF + doc = REXML::Document.new(xml) + assert_raise(RuntimeError) do + doc.root.children.first.value + end + REXML::Document.entity_expansion_limit = 100 + assert_equal(100, REXML::Document.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 +end +require "rexml/document" +require "test/unit" + +class REXML::TestDocument < Test::Unit::TestCase + def test_new + doc = REXML::Document.new(< +Hello world! +EOF + assert_equal("Hello world!", doc.root.children.first.value) + end + + XML_WITH_NESTED_ENTITY = < + + + + + + + +]> + +&a; + +EOF + + def test_entity_expansion_limit + doc = REXML::Document.new(XML_WITH_NESTED_ENTITY) + assert_raise(RuntimeError) do + doc.root.children.first.value + end + REXML::Document.entity_expansion_limit = 100 + assert_equal(100, REXML::Document.entity_expansion_limit) + doc = REXML::Document.new(XML_WITH_NESTED_ENTITY) + assert_raise(RuntimeError) do + doc.root.children.first.value + end + assert_equal(101, doc.entity_expansion_count) + end +end -- cgit v1.2.3