From 10f820b18d8c6011a7f98e56ac859903c56b15e6 Mon Sep 17 00:00:00 2001 From: usa Date: Mon, 27 Oct 2014 11:24:04 +0000 Subject: merge revision(s) 48161: * lib/rexml/entity.rb: keep the entity size within the limitation. reported by Willis Vandevanter 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 --- ChangeLog | 6 ++++++ lib/rexml/entity.rb | 6 ++++++ test/rexml/test_document.rb | 27 +++++++++++++++++++++++++++ test/rexml/test_entity.rb | 16 ++++++++++++++++ version.h | 6 +++--- 5 files changed, 58 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1e8d9fc054..5568b7a2ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Oct 27 20:23:27 2014 NAKAMURA Usaku + + * lib/rexml/entity.rb: keep the entity size within the limitation. + reported by Willis Vandevanter and + patched by nahi. + Thu Oct 24 12:00:55 2014 CHIKANAGA Tomoyuki * ext/openssl/lib/openssl/ssl-internal.rb (DEFAULT_PARAMS): override diff --git a/lib/rexml/entity.rb b/lib/rexml/entity.rb index 3d81fbc738..dc3f666cad 100644 --- a/lib/rexml/entity.rb +++ b/lib/rexml/entity.rb @@ -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 diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb index ab0b1e4e96..b89e7372ad 100644 --- a/test/rexml/test_document.rb +++ b/test/rexml/test_document.rb @@ -45,6 +45,20 @@ EOF &a; +EOF + + XML_WITH_NESTED_PARAMETER_ENTITY = < + + + + + + + ++]> + EOF XML_WITH_4_ENTITY_EXPANSION = <