Skip to content

Commit b8e1016

Browse files
committed
"keep the entity size within the limitation"
See ruby/ruby@9cdd297
1 parent 575b395 commit b8e1016

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

lib/ruby/1.8/rexml/entity.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ def value
138138
matches = @value.scan(PEREFERENCE_RE)
139139
rv = @value.clone
140140
if @parent
141+
sum = 0
141142
matches.each do |entity_reference|
142143
entity_value = @parent.entity( entity_reference[0] )
144+
if sum + entity_value.bytesize > Document.entity_expansion_text_limit
145+
raise "entity expansion has grown too large"
146+
else
147+
sum += entity_value.bytesize
148+
end
143149
rv.gsub!( /%#{entity_reference};/um, entity_value )
144150
end
145151
end

lib/ruby/1.9/rexml/entity.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ def value
138138
matches = @value.scan(PEREFERENCE_RE)
139139
rv = @value.clone
140140
if @parent
141+
sum = 0
141142
matches.each do |entity_reference|
142143
entity_value = @parent.entity( entity_reference[0] )
144+
if sum + entity_value.bytesize > Document.entity_expansion_text_limit
145+
raise "entity expansion has grown too large"
146+
else
147+
sum += entity_value.bytesize
148+
end
143149
rv.gsub!( /%#{entity_reference.join};/um, entity_value )
144150
end
145151
end

lib/ruby/2.0/rexml/entity.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ def value
138138
matches = @value.scan(PEREFERENCE_RE)
139139
rv = @value.clone
140140
if @parent
141+
sum = 0
141142
matches.each do |entity_reference|
142143
entity_value = @parent.entity( entity_reference[0] )
144+
if sum + entity_value.bytesize > Document.entity_expansion_text_limit
145+
raise "entity expansion has grown too large"
146+
else
147+
sum += entity_value.bytesize
148+
end
143149
rv.gsub!( /%#{entity_reference.join};/um, entity_value )
144150
end
145151
end

0 commit comments

Comments
 (0)