summaryrefslogtreecommitdiff
path: root/test/rexml/test_document.rb
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-27 11:18:02 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-27 11:18:02 +0000
commit9cdd297a2959c9c01eeee4a743b4777f28ffc9e4 (patch)
treed7f329f93fe513ee02b9bf2a5e9eb905aedfd475 /test/rexml/test_document.rb
parente45b215fdd16f4fefc8f97f2391ef532f10c8f50 (diff)
* 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/trunk@48161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rexml/test_document.rb')
-rw-r--r--test/rexml/test_document.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb
index db3c0e97c3..171d480557 100644
--- a/test/rexml/test_document.rb
+++ b/test/rexml/test_document.rb
@@ -48,6 +48,20 @@ EOF
</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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE member [
@@ -86,6 +100,19 @@ EOF
REXML::Security.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::Security.entity_expansion_limit = 100
+ assert_equal(100, REXML::Security.entity_expansion_limit)
+ assert_raise(REXML::ParseException) do
+ REXML::Document.new(XML_WITH_NESTED_PARAMETER_ENTITY)
+ end
+ ensure
+ REXML::Security.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