Sha256: fc7f12ea0597c5ee8239e2fa4fc642ffd50bdbd75cef3035a5a86aeb818dd9ce

Contents?: true

Size: 1.31 KB

Versions: 150

Compression:

Stored size: 1.31 KB

Contents

# Fixes the rexml vulnerability disclosed at:
# http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/
# This fix is identical to rexml-expansion-fix version 1.0.1
require 'rexml/rexml'

# Earlier versions of rexml defined REXML::Version, newer ones REXML::VERSION
unless (defined?(REXML::VERSION) ? REXML::VERSION : REXML::Version) > "3.1.7.2"
  require 'rexml/document'

  # REXML in 1.8.7 has the patch but didn't update Version from 3.1.7.2.
  unless REXML::Document.respond_to?(:entity_expansion_limit=)
    require 'rexml/entity'

    module REXML
      class Entity < Child
        undef_method :unnormalized
        def unnormalized
          document.record_entity_expansion! if document
          v = value()
          return nil if v.nil?
          @unnormalized = Text::unnormalize(v, parent)
          @unnormalized
        end
      end
      class Document < Element
        @@entity_expansion_limit = 10_000
        def self.entity_expansion_limit= val
          @@entity_expansion_limit = val
        end

        def record_entity_expansion!
          @number_of_expansions ||= 0
          @number_of_expansions += 1
          if @number_of_expansions > @@entity_expansion_limit
            raise "Number of entity expansions exceeded, processing aborted."
          end
        end
      end
    end
  end
end

Version data entries

150 entries across 119 versions & 14 rubygems

Version Path
depengine-0.0.31 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.31 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.30 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.30 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.29 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.29 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.28 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.28 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.27 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.27 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.26 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.26 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.25 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.25 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.24 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.24 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.23 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.23 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.22 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb
depengine-0.0.22 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/rexml.rb