Sha256: 739d5dac337b646519ba54a64da0f1168cb19a8d3958105f45e0256bd2befe9d

Contents?: true

Size: 1.44 KB

Versions: 8

Compression:

Stored size: 1.44 KB

Contents

# Copyright (c) 2008 Michael Koziarski <michael@koziarski.com>
# 
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
# 
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

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

module REXML
  class Entity < Child
    def unnormalized
      document.record_entity_expansion!
      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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
exact4r-1.7 ./lib/ews/transaction/rexml-expansion-fix.rb
exact4r-1.6 ./lib/ews/transaction/rexml-expansion-fix.rb
exact4r-1.5 ./lib/ews/transaction/rexml-expansion-fix.rb
exact4r-1.4 ./lib/ews/transaction/rexml-expansion-fix.rb
exact4r-1.2 ./lib/ews/transaction/rexml-expansion-fix.rb
exact4r-1.1 ./lib/ews/transaction/rexml-expansion-fix.rb
exact4r-1.0 ./lib/ews/transaction/rexml-expansion-fix.rb
exact4r-0.9.3 ./lib/ews/transaction/rexml-expansion-fix.rb