From 23ccbdf52188b78427f41d75b1a4b81959ac9876 Mon Sep 17 00:00:00 2001 From: usa Date: Thu, 13 Nov 2014 13:39:32 +0000 Subject: merge revision(s) 48402: * lib/rexml/document.rb: add REXML::Document#document. reported by Tomas Hoger and patched by nahi. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@48406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/rexml/document.rb | 4 ++++ lib/rexml/entity.rb | 1 + test/rexml/test_document.rb | 53 ++++++++++++++++++++++++++++++++++++++++++++- version.h | 8 +++---- 5 files changed, 66 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5568b7a2ac..7d97830ddc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Nov 13 22:36:17 2014 CHIKANAGA Tomoyuki + + * lib/rexml/document.rb: add REXML::Document#document. + reported by Tomas Hoger and patched by nahi. + Mon Oct 27 20:23:27 2014 NAKAMURA Usaku * lib/rexml/entity.rb: keep the entity size within the limitation. diff --git a/lib/rexml/document.rb b/lib/rexml/document.rb index 2f9e659772..9f94d9707a 100644 --- a/lib/rexml/document.rb +++ b/lib/rexml/document.rb @@ -240,6 +240,10 @@ module REXML end end + def document + self + end + private def build( source ) Parsers::TreeParser.new( source, self ).parse diff --git a/lib/rexml/entity.rb b/lib/rexml/entity.rb index dc3f666cad..d10b051f18 100644 --- a/lib/rexml/entity.rb +++ b/lib/rexml/entity.rb @@ -157,6 +157,7 @@ module REXML # 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', '>' ) diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb index b89e7372ad..bf40b49815 100644 --- a/test/rexml/test_document.rb +++ b/test/rexml/test_document.rb @@ -45,6 +45,22 @@ EOF &a; +EOF + + XML_WITH_NESTED_EMPTY_ENTITY = < + + + + + + + +]> + +&a; + EOF XML_WITH_NESTED_PARAMETER_ENTITY = < -+]> +]> + +EOF + + XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY = < + + + + + + + +]> EOF @@ -87,6 +117,18 @@ EOF 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 +137,15 @@ EOF 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 diff --git a/version.h b/version.h index 923231cba1..728f9df1e9 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 550 +#define RUBY_PATCHLEVEL 551 -#define RUBY_RELEASE_DATE "2014-10-27" +#define RUBY_RELEASE_DATE "2014-11-13" #define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 10 -#define RUBY_RELEASE_DAY 27 +#define RUBY_RELEASE_MONTH 11 +#define RUBY_RELEASE_DAY 13 #include "ruby/version.h" -- cgit v1.2.3