From 9cdd297a2959c9c01eeee4a743b4777f28ffc9e4 Mon Sep 17 00:00:00 2001 From: usa Date: Mon, 27 Oct 2014 11:18:02 +0000 Subject: * 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/trunk@48161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rexml/entity.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/rexml') diff --git a/lib/rexml/entity.rb b/lib/rexml/entity.rb index 39f3900075..f447202394 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 > Security.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 -- cgit v1.2.3