Permalink
Browse files

merge revision(s) 48402:

	* lib/rexml/document.rb: add REXML::Document#document.
	  reported by Tomas Hoger <thoger@redhat.com> 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
  • Loading branch information...
1 parent 10f820b commit 23ccbdf52188b78427f41d75b1a4b81959ac9876 @unak unak committed Nov 13, 2014
Showing with 66 additions and 5 deletions.
  1. +5 −0 ChangeLog
  2. +4 −0 lib/rexml/document.rb
  3. +1 −0 lib/rexml/entity.rb
  4. +52 −1 test/rexml/test_document.rb
  5. +4 −4 version.h
View
@@ -1,3 +1,8 @@
+Thu Nov 13 22:36:17 2014 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
+
+ * lib/rexml/document.rb: add REXML::Document#document.
+ reported by Tomas Hoger <thoger@redhat.com> and patched by nahi.
+
Mon Oct 27 20:23:27 2014 NAKAMURA Usaku <usa@ruby-lang.org>
* lib/rexml/entity.rb: keep the entity size within the limitation.
@@ -240,6 +240,10 @@ def record_entity_expansion
end
end
+ def document
+ self
+ end
+
private
def build( source )
Parsers::TreeParser.new( source, self ).parse
View
@@ -157,6 +157,7 @@ def value
# 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', '>' )
@@ -47,6 +47,22 @@ def test_new
</member>
EOF
+ XML_WITH_NESTED_EMPTY_ENTITY = <<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE member [
+ <!ENTITY a "&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;">
+ <!ENTITY b "&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;">
+ <!ENTITY c "&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;">
+ <!ENTITY d "&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;">
+ <!ENTITY e "&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;">
+ <!ENTITY f "&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;">
+ <!ENTITY g "">
+]>
+<member>
+&a;
+</member>
+EOF
+
XML_WITH_NESTED_PARAMETER_ENTITY = <<EOF
<!DOCTYPE root [
<!ENTITY % a "BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.">
@@ -57,7 +73,21 @@ def test_new
<!ENTITY % f "%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;">
<!ENTITY % g "%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;">
<!ENTITY test "test %g;">
-+]>
+]>
+<cd></cd>
+EOF
+
+ XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY = <<EOF
+<!DOCTYPE root [
+ <!ENTITY % a "">
+ <!ENTITY % b "%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;">
+ <!ENTITY % c "%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;">
+ <!ENTITY % d "%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;">
+ <!ENTITY % e "%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;">
+ <!ENTITY % f "%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;">
+ <!ENTITY % g "%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;">
+ <!ENTITY test "test %g;">
+]>
<cd></cd>
EOF
@@ -87,6 +117,18 @@ def test_entity_expansion_limit
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 @@ def test_entity_expansion_limit
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
View
@@ -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"

0 comments on commit 23ccbdf

Please sign in to comment.