mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
merge revision(s) 48161:
* lib/rexml/entity.rb: keep the entity size within the limitation. reported by Willis Vandevanter <will@silentrobots.com> and patched by nahi. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@48164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
26c0acf5a7
commit
10f820b18d
5 changed files with 58 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
|||
Mon Oct 27 20:23:27 2014 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* lib/rexml/entity.rb: keep the entity size within the limitation.
|
||||
reported by Willis Vandevanter <will@silentrobots.com> and
|
||||
patched by nahi.
|
||||
|
||||
Thu Oct 24 12:00:55 2014 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
|
||||
|
||||
* ext/openssl/lib/openssl/ssl-internal.rb (DEFAULT_PARAMS): override
|
||||
|
|
|
@ -138,8 +138,14 @@ module REXML
|
|||
matches = @value.scan(PEREFERENCE_RE)
|
||||
rv = @value.clone
|
||||
if @parent
|
||||
sum = 0
|
||||
matches.each do |entity_reference|
|
||||
entity_value = @parent.entity( entity_reference[0] )
|
||||
if sum + entity_value.bytesize > Document.entity_expansion_text_limit
|
||||
raise "entity expansion has grown too large"
|
||||
else
|
||||
sum += entity_value.bytesize
|
||||
end
|
||||
rv.gsub!( /%#{entity_reference.join};/um, entity_value )
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,6 +45,20 @@ EOF
|
|||
<member>
|
||||
&a;
|
||||
</member>
|
||||
EOF
|
||||
|
||||
XML_WITH_NESTED_PARAMETER_ENTITY = <<EOF
|
||||
<!DOCTYPE root [
|
||||
<!ENTITY % a "BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.">
|
||||
<!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
|
||||
|
@ -85,6 +99,19 @@ EOF
|
|||
REXML::Document.entity_expansion_limit = 10000
|
||||
end
|
||||
|
||||
def test_entity_expansion_limit_for_parameter_entity
|
||||
assert_raise(REXML::ParseException) do
|
||||
REXML::Document.new(XML_WITH_NESTED_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_PARAMETER_ENTITY)
|
||||
end
|
||||
ensure
|
||||
REXML::Document.entity_expansion_limit = 10000
|
||||
end
|
||||
|
||||
def test_tag_in_cdata_with_not_ascii_only_but_ascii8bit_encoding_source
|
||||
tag = "<b>...</b>"
|
||||
message = "こんにちは、世界!" # Hello world! in Japanese
|
||||
|
|
|
@ -122,6 +122,22 @@ class EntityTester < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_entity_string_limit_for_parameter_entity
|
||||
template = '<!DOCTYPE bomb [ <!ENTITY % a "^" > <!ENTITY bomb "$" > ]><root/>'
|
||||
len = 5120 # 5k per entity
|
||||
template.sub!(/\^/, "B" * len)
|
||||
|
||||
# 10k is OK
|
||||
entities = '%a;' * 2 # 5k entity * 2 = 10k
|
||||
REXML::Document.new(template.sub(/\$/, entities))
|
||||
|
||||
# above 10k explodes
|
||||
entities = '%a;' * 3 # 5k entity * 2 = 15k
|
||||
assert_raises(REXML::ParseException) do
|
||||
REXML::Document.new(template.sub(/\$/, entities))
|
||||
end
|
||||
end
|
||||
|
||||
def test_raw
|
||||
source = '<!DOCTYPE foo [
|
||||
<!ENTITY ent "replace">
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#define RUBY_VERSION "1.9.3"
|
||||
#define RUBY_PATCHLEVEL 549
|
||||
#define RUBY_PATCHLEVEL 550
|
||||
|
||||
#define RUBY_RELEASE_DATE "2014-10-24"
|
||||
#define RUBY_RELEASE_DATE "2014-10-27"
|
||||
#define RUBY_RELEASE_YEAR 2014
|
||||
#define RUBY_RELEASE_MONTH 10
|
||||
#define RUBY_RELEASE_DAY 24
|
||||
#define RUBY_RELEASE_DAY 27
|
||||
|
||||
#include "ruby/version.h"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue