8000 merge revision(s) r48402: · github/ruby@eac759b · GitHub
[go: up one dir, main page]

Skip to content

Commit eac759b

Browse files
committed
merge revision(s) r48402:
* 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_1@48404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent d4239a9 commit eac759b

File tree

5 files changed

+65
-4
lines changed

5 files changed

+65
-4
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Thu Nov 13 22:32:34 2014 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
2+
3+
* lib/rexml/document.rb: add REXML::Document#document.
4+
reported by Tomas Hoger <thoger@redhat.com> and patched by nahi.
5+
16
Thu Nov 6 22:57:43 2014 Naohisa Goto <ngotogenome@gmail.com>
27

38
* bignum.c (absint_numwords_generic): set an array element after

lib/rexml/document.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ def record_entity_expansion
278278
end
279279
end
280280

281+
def document
282+
self
283+
end
284+
281285
private
282286
def build( source )
283287
Parsers::TreeParser.new( source, self ).parse

lib/rexml/entity.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def value
157157

158158
# This is a set of entity constants -- the ones defined in the XML
159159
# specification. These are +gt+, +lt+, +amp+, +quot+ and +apos+.
160+
# CAUTION: these entities does not have parent and document
160161
module EntityConst
161162
# +>+
162163
GT = Entity.new( 'gt', '>' )

test/rexml/test_document.rb

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,23 @@ def test_new
4747
</member>
4848
EOF
4949

50-
XML_WITH_NESTED_PARAMETER_ENTITY = <<EOF
50+
XML_WITH_NESTED_EMPTY_ENTITY = <<EOF
51+
<?xml version="1.0" encoding="UTF-8"?>
52+
<!DOCTYPE member [
53+
<!ENTITY a "&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;">
54+
<!ENTITY b "&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;">
55+
<!ENTITY c "&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;">
56+
<!ENTITY d "&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;">
57+
<!ENTITY e "&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;">
58+
<!ENTITY f "&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;">
59+
<!ENTITY g "">
60+
]>
61+
<member>
62+
&a;
63+
</member>
64+
EOF
65+
66+
XML_WITH_NESTED_PARAMETER_ENTITY = <<EOF
5167
<!DOCTYPE root [
5268
<!ENTITY % a "BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.">
5369
<!ENTITY % b "%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;">
@@ -59,6 +75,20 @@ def test_new
5975
<!ENTITY test "test %g;">
6076
]>
6177
<cd></cd>
78+
EOF
79+
80+
XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY = <<EOF
81+
<!DOCTYPE root [
82+
<!ENTITY % a "">
83+
<!ENTITY % b "%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;">
84+
<!ENTITY % c "%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;">
85+
<!ENTITY % d "%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;">
86+
<!ENTITY % e "%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;">
87+
<!ENTITY % f "%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;">
88+
<!ENTITY % g "%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;">
89+
<!ENTITY test "test %g;">
90+
]>
91+
<cd></cd>
6292
EOF
6393

6494
XML_WITH_4_ENTITY_EXPANSION = <<EOF
@@ -87,6 +117,18 @@ def test_entity_expansion_limit
87117
end
88118
assert_equal(101, doc.entity_expansion_count)
89119

120+
doc = REXML::Document.new(XML_WITH_NESTED_EMPTY_ENTITY)
121+
assert_raise(RuntimeError) do
122+
doc.root.children.first.value
123+
end
124+
REXML::Security.entity_expansion_limit = 100
125+
assert_equal(100, REXML::Security.entity_expansion_limit)
126+
doc = REXML::Document.new(XML_WITH_NESTED_EMPTY_ENTITY)
127+
assert_raise(RuntimeError) do
128+
doc.root.children.first.value
129+
end
130+
assert_equal(101, doc.entity_expansion_count)
131+
90132
REXML::Security.entity_expansion_limit = 4
91133
doc = REXML::Document.new(XML_WITH_4_ENTITY_EXPANSION)
92134
assert_equal("\na\na a\n<\n", doc.root.children.first.value)
@@ -108,6 +150,15 @@ def test_entity_expansion_limit_for_parameter_entity
108150
assert_raise(REXML::ParseException) do
109151
REXML::Document.new(XML_WITH_NESTED_PARAMETER_ENTITY)
110152
end
153+
154+
assert_raise(REXML::ParseException) do
155+
REXML::Document.new(XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY)
156+
end
157+
REXML::Security.entity_expansion_limit = 100
158+
assert_equal(100, REXML::Security.entity_expansion_limit)
159+
assert_raise(REXML::ParseException) do
160+
REXML::Document.new(XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY)
161+
end
111162
ensure
112163
REXML::Security.entity_expansion_limit = 10000
113164
end

version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#define RUBY_VERSION "2.1.5"
2-
#define RUBY_RELEASE_DATE "2014-11-06"
3-
#define RUBY_PATCHLEVEL 272
2+
#define RUBY_RELEASE_DATE "2014-11-13"
3+
#define RUBY_PATCHLEVEL 273
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 11
7-
#define RUBY_RELEASE_DAY 6
7+
#define RUBY_RELEASE_DAY 13
88

99
#include "ruby/version.h"
1010

0 commit comments

Comments
 (0)
0