Index: ChangeLog =================================================================== --- ChangeLog (revision 48402) +++ ChangeLog (revision 48403) @@ -1,3 +1,8 @@ +Thu Nov 13 22:31:50 2014 CHIKANAGA Tomoyuki + + * lib/rexml/document.rb: add REXML::Document#document. + reported by Tomas Hoger and patched by nahi. + Mon Oct 27 20:21:05 2014 NAKAMURA Usaku * lib/rexml/entity.rb: keep the entity size within the limitation. Index: lib/rexml/document.rb =================================================================== --- lib/rexml/document.rb (revision 48402) +++ lib/rexml/document.rb (revision 48403) @@ -278,6 +278,10 @@ end end + def document + self + end + private def build( source ) Parsers::TreeParser.new( source, self ).parse Index: lib/rexml/entity.rb =================================================================== --- lib/rexml/entity.rb (revision 48402) +++ lib/rexml/entity.rb (revision 48403) @@ -157,6 +157,7 @@ # This is a set of entity constants -- the ones defined in the XML # specification. These are +gt+, +lt+, +amp+, +quot+ and +apos+. + # CAUTION: these entities does not have parent and document module EntityConst # +>+ GT = Entity.new( 'gt', '>' ) Index: test/rexml/test_document.rb =================================================================== --- test/rexml/test_document.rb (revision 48402) +++ test/rexml/test_document.rb (revision 48403) @@ -47,6 +47,22 @@ EOF + XML_WITH_NESTED_EMPTY_ENTITY = < + + + + + + + +]> + +&a; + +EOF + XML_WITH_NESTED_PARAMETER_ENTITY = < @@ -60,6 +76,19 @@ ]> EOF + XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY = < + + + + + + + +]> + +EOF XML_WITH_4_ENTITY_EXPANSION = < @@ -87,6 +116,18 @@ end assert_equal(101, doc.entity_expansion_count) + doc = REXML::Document.new(XML_WITH_NESTED_EMPTY_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_EMPTY_ENTITY) + assert_raise(RuntimeError) do + 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<\n", doc.root.children.first.value) @@ -95,6 +136,15 @@ assert_raise(RuntimeError) do doc.root.children.first.value end + + assert_raise(REXML::ParseException) do + REXML::Document.new(XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY) + end + REXML::Document.entity_expansion_limit = 100 + assert_equal(100, REXML::Document.entity_expansion_limit) + assert_raise(REXML::ParseException) do + REXML::Document.new(XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY) + end ensure REXML::Document.entity_expansion_limit = 10000 end Index: . =================================================================== --- . (revision 48402) +++ . (revision 48403) Property changes on: . ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r48402