Sha256: 0c84223f7408dfed1e060432279aec092f58ac8b6bf65c901d19da77aaff44aa

Contents?: true

Size: 871 Bytes

Versions: 26

Compression:

Stored size: 871 Bytes

Contents

class SafeString < String
  def to_s
    self
  end
  def to_s_xss_protected
    self
  end
end

class String
  def mark_as_xss_protected
    SafeString.new(self)
  end
end

class NilClass
  def mark_as_xss_protected
    self
  end
end

# ERB::Util.h and (include ERB::Util; h) are different methods
module ERB::Util
  class <<self
    def h_with_xss_protection(*args)
      h_without_xss_protection(*args).mark_as_xss_protected
    end
    alias_method_chain :h, :xss_protection
  end
  
    def h_with_xss_protection(*args)
      h_without_xss_protection(*args).mark_as_xss_protected
    end
    alias_method_chain :h, :xss_protection
end

class Object
  def to_s_xss_protected
    ERB::Util.h(to_s).mark_as_xss_protected
  end
end

class Array
  def join_xss_protected(sep="")
    map(&:to_s_xss_protected).join(sep.to_s_xss_protected).mark_as_xss_protected
  end
end

Version data entries

26 entries across 26 versions & 5 rubygems

Version Path
codez-tarantula-0.5.5 vendor/xss-shield/lib/xss_shield/safe_string.rb
codez-tarantula-0.5.4 vendor/xss-shield/lib/xss_shield/safe_string.rb
artmotion-xss_shield-0.0.1 lib/xss_shield/safe_string.rb
artmotion-xss_shield-0.0.2 lib/xss_shield/safe_string.rb
relevance-tarantula-0.0.1 vendor/xss-shield/lib/xss_shield/safe_string.rb
relevance-tarantula-0.0.2 vendor/xss-shield/lib/xss_shield/safe_string.rb
relevance-tarantula-0.0.3 vendor/xss-shield/lib/xss_shield/safe_string.rb
relevance-tarantula-0.0.5 vendor/xss-shield/lib/xss_shield/safe_string.rb
relevance-tarantula-0.0.6 vendor/xss-shield/lib/xss_shield/safe_string.rb
relevance-tarantula-0.0.7.1 vendor/xss-shield/lib/xss_shield/safe_string.rb
relevance-tarantula-0.0.7 vendor/xss-shield/lib/xss_shield/safe_string.rb
relevance-tarantula-0.0.8.0 vendor/xss-shield/lib/xss_shield/safe_string.rb
relevance-tarantula-0.0.8.1 vendor/xss-shield/lib/xss_shield/safe_string.rb
romanbsd-tarantula-0.1.8 vendor/xss-shield/lib/xss_shield/safe_string.rb
romanbsd-tarantula-0.2.0 vendor/xss-shield/lib/xss_shield/safe_string.rb
codez-tarantula-0.5.3 vendor/xss-shield/lib/xss_shield/safe_string.rb
codez-tarantula-0.5.1 vendor/xss-shield/lib/xss_shield/safe_string.rb
codez-tarantula-0.5.0 vendor/xss-shield/lib/xss_shield/safe_string.rb
tarantula-0.5.1 vendor/xss-shield/lib/xss_shield/safe_string.rb
tarantula-0.5.0 vendor/xss-shield/lib/xss_shield/safe_string.rb