Skip to content

Commit

Permalink
Update 1.8.7 rexml to latest.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Oct 28, 2014
1 parent 57ecaf6 commit 566b9d6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
10 changes: 6 additions & 4 deletions lib/ruby/1.8/rexml/document.rb
Expand Up @@ -213,16 +213,18 @@ def Document::entity_expansion_limit
return @@entity_expansion_limit
end

@@entity_expansion_text_limit = 10_240

# Set the entity expansion limit. By default the limit is set to 10240.
#
# Deprecated. Use REXML.entity_expansion_text_limit= instead.
def Document::entity_expansion_text_limit=( val )
@@entity_expansion_text_limit = val
REXML.entity_expansion_text_limit = val
end

# Get the entity expansion limit. By default the limit is set to 10000.
#
# Deprecated. Use REXML.entity_expansion_text_limit instead.
def Document::entity_expansion_text_limit
return @@entity_expansion_text_limit
return REXML.entity_expansion_text_limit
end

attr_reader :entity_expansion_count
Expand Down
12 changes: 12 additions & 0 deletions lib/ruby/1.8/rexml/rexml.rb
Expand Up @@ -29,4 +29,16 @@ module REXML

Copyright = COPYRIGHT
Version = VERSION

@@entity_expansion_text_limit = 10_240

# Set the entity expansion limit. By default the limit is set to 10240.
def self.entity_expansion_text_limit=( val )
@@entity_expansion_text_limit = val
end

# Get the entity expansion limit. By default the limit is set to 10240.
def self.entity_expansion_text_limit
return @@entity_expansion_text_limit
end
end
4 changes: 2 additions & 2 deletions lib/ruby/1.8/rexml/text.rb
@@ -1,3 +1,4 @@
require 'rexml/rexml'
require 'rexml/entity'
require 'rexml/doctype'
require 'rexml/child'
Expand Down Expand Up @@ -311,7 +312,7 @@ def Text::unnormalize( string, doctype=nil, filter=nil, illegal=nil )
sum = 0
string.gsub( /\r\n?/, "\n" ).gsub( REFERENCE ) {
s = Text.expand($&, doctype, filter)
if sum + s.bytesize > Document.entity_expansion_text_limit
if sum + s.bytesize > REXML.entity_expansion_text_limit
raise "entity expansion has grown too large"
else
sum += s.bytesize
Expand All @@ -338,6 +339,5 @@ def Text.expand(ref, doctype, filter)
entity_value ? entity_value.value : ref
end
end

end
end

0 comments on commit 566b9d6

Please sign in to comment.