* lib/rexml/document.rb: move entity_expansion_limit accessor to ...

* lib/rexml/rexml.rb: ... here to make rexml/text independent from
  REXML::Document. It causes circular require.
* lib/rexml/document.rb (REXML::Document.entity_expansion_limit):
  deprecated.
* lib/rexml/document.rb (REXML::Document.entity_expansion_limit=):
  deprecated.
* lib/rexml/text.rb: add missing require "rexml/rexml" for
  REXML.entity_expansion_limit.
  Reported by Robert Ulejczyk. Thanks!!! [ruby-core:52895] [Bug #7961]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2013-02-26 14:30:40 +00:00
Родитель 684ce8403c
Коммит ea2e083a1d
4 изменённых файлов: 33 добавлений и 5 удалений

Просмотреть файл

@ -1,3 +1,16 @@
Tue Feb 26 23:26:13 2013 Kouhei Sutou <kou@cozmixng.org>
* lib/rexml/document.rb: move entity_expansion_limit accessor to ...
* lib/rexml/rexml.rb: ... here to make rexml/text independent from
REXML::Document. It causes circular require.
* lib/rexml/document.rb (REXML::Document.entity_expansion_limit):
deprecated.
* lib/rexml/document.rb (REXML::Document.entity_expansion_limit=):
deprecated.
* lib/rexml/text.rb: add missing require "rexml/rexml" for
REXML.entity_expansion_limit.
Reported by Robert Ulejczyk. Thanks!!! [ruby-core:52895] [Bug #7961]
Tue Feb 26 15:12:11 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* tool/mkconfig.rb: reconstruct comma separated list values. a

Просмотреть файл

@ -255,16 +255,18 @@ module REXML
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 10240.
#
# 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

Просмотреть файл

@ -28,4 +28,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

Просмотреть файл

@ -1,3 +1,4 @@
require 'rexml/rexml'
require 'rexml/entity'
require 'rexml/doctype'
require 'rexml/child'
@ -383,7 +384,7 @@ module REXML
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