ruby-changes:7796
From: shugo <ko1@a...>
Date: Sat, 13 Sep 2008 10:40:53 +0900 (JST)
Subject: [ruby-changes:7796] Ruby:r19317 (trunk): * text/rexml/test_document.rb (test_entity_expansion_limit): added tests.
shugo 2008-09-13 10:40:36 +0900 (Sat, 13 Sep 2008) New Revision: 19317 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19317 Log: * text/rexml/test_document.rb (test_entity_expansion_limit): added tests. Modified files: trunk/test/rexml/test_document.rb Index: test/rexml/test_document.rb =================================================================== --- test/rexml/test_document.rb (revision 19316) +++ test/rexml/test_document.rb (revision 19317) @@ -67,6 +67,18 @@ </member> EOF + XML_WITH_4_ENTITY_EXPANSION = <<EOF +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE member [ + <!ENTITY a "a"> + <!ENTITY a2 "&a; &a;"> +]> +<member> +&a; +&a2; +</member> +EOF + def test_entity_expansion_limit doc = REXML::Document.new(XML_WITH_NESTED_ENTITY) assert_raise(RuntimeError) do @@ -79,5 +91,16 @@ doc.root.children.first.value end assert_equal(101, doc.entity_expansion_count) + + REXML::Document.entity_expansion_limit = 4 + doc = REXML::Document.new(XML_WITH_4_ENTITY_EXPANSION) + assert_equal("\na\na a\n", doc.root.children.first.value) + REXML::Document.entity_expansion_limit = 3 + doc = REXML::Document.new(XML_WITH_4_ENTITY_EXPANSION) + assert_raise(RuntimeError) do + doc.root.children.first.value + end + ensure + REXML::Document.entity_expansion_limit = 10000 end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/