Sha256: 02f64a1823b84daf8c8d30b68cc94cdbbca8c15e90bc1aebcacb8a66a9f1a562

Contents?: true

Size: 1.08 KB

Versions: 14

Compression:

Stored size: 1.08 KB

Contents

require 'rexml/document'
require 'rexml/entity'

# 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

# Earlier versions of rexml defined REXML::Version, newer ones REXML::VERSION
unless REXML::Document.respond_to?(:entity_expansion_limit=)
  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

Version data entries

14 entries across 13 versions & 8 rubygems

Version Path
p8-castronaut-0.6.1.1 vendor/activesupport/lib/active_support/core_ext/rexml.rb
relevance-castronaut-0.6.0 vendor/activesupport/lib/active_support/core_ext/rexml.rb
relevance-castronaut-0.6.1 vendor/activesupport/lib/active_support/core_ext/rexml.rb
relevance-castronaut-0.7.4 vendor/activesupport/lib/active_support/core_ext/rexml.rb
relevance-castronaut-0.7.5 vendor/activesupport/lib/active_support/core_ext/rexml.rb
nbudin-castronaut-0.7.5 vendor/activesupport/lib/active_support/core_ext/rexml.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activesupport/pkg/activesupport-2.2.2/lib/active_support/core_ext/rexml.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activesupport/lib/active_support/core_ext/rexml.rb
factorylabs-castronaut-0.7.5 vendor/activesupport/lib/active_support/core_ext/rexml.rb
activesupport-2.2.3 lib/active_support/core_ext/rexml.rb
activesupport-2.2.2 lib/active_support/core_ext/rexml.rb
mack-active_record-0.8.2 lib/gems/activesupport-2.2.2/lib/active_support/core_ext/rexml.rb
mack-facets-0.8.3.1 lib/gems/activesupport-2.2.2/lib/active_support/core_ext/rexml.rb
mack-facets-0.8.3 lib/gems/activesupport-2.2.2/lib/active_support/core_ext/rexml.rb