summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-13 13:35:51 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-13 13:35:51 +0000
commitd6ea8d18f9ffb76aa3541087e55e90c030295129 (patch)
treeb1773e49466ec5b23a70bd1995708735a352a48d
parentfd25950ec7234ea48fc98da064cbe43b7701237c (diff)
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_2_0_0@48403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/rexml/document.rb4
-rw-r--r--lib/rexml/entity.rb1
-rw-r--r--test/rexml/test_document.rb50
-rw-r--r--version.h6
5 files changed, 63 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index fb47fef..02ae486 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Nov 13 22:31:50 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.
+
Thu Nov 6 17:31:51 2014 Naohisa Goto <ngotogenome@gmail.com>
* compile.c (compile_data_alloc): add padding when strict alignment
diff --git a/lib/rexml/document.rb b/lib/rexml/document.rb
index 76679d1..e5cef13 100644
--- a/lib/rexml/document.rb
+++ b/lib/rexml/document.rb
@@ -278,6 +278,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 dc3f666..d10b051 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 392ca58..1f31635 100644
--- a/test/rexml/test_document.rb
+++ b/test/rexml/test_document.rb
@@ -47,6 +47,22 @@ EOF
</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.">
@@ -60,6 +76,19 @@ EOF
]>
<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
XML_WITH_4_ENTITY_EXPANSION = <<EOF
<?xml version="1.0" encoding="UTF-8"?>
@@ -87,6 +116,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 +136,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 9e10b43..b7876f7 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.0.0"
-#define RUBY_RELEASE_DATE "2014-11-06"
-#define RUBY_PATCHLEVEL 597
+#define RUBY_RELEASE_DATE "2014-11-13"
+#define RUBY_PATCHLEVEL 598
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 11
-#define RUBY_RELEASE_DAY 6
+#define RUBY_RELEASE_DAY 13
#include "ruby/version.h"