Sha256: 3a021d2adbd136a5898b6118657649ceb16344d1188fd290b9686c8f30f01341

Contents?: true

Size: 1.3 KB

Versions: 26

Compression:

Stored size: 1.3 KB

Contents

class Module
  def mark_helpers_as_xss_protected(*ms)
    ms.each do |m|
      begin
        instance_method("#{m}_with_xss_protection")
      rescue NameError
        define_method :"#{m}_with_xss_protection" do |*args|
          send(:"#{m}_without_xss_protection", *args).mark_as_xss_protected
        end
        alias_method_chain m, :xss_protection
      end
    end
  end
end

class ActionView::Base
  mark_helpers_as_xss_protected :javascript_include_tag,
                                :stylesheet_link_tag,
                                :render,
                                :text_field_tag,
                                :submit_tag,
                                :radio_button,
                                :text_area,
                                :auto_discovery_link_tag,
                                :image_tag

  def link_to_with_xss_protection(text, *args)
    link_to_without_xss_protection(text.to_s_xss_protected, *args).mark_as_xss_protected
  end
  alias_method_chain :link_to, :xss_protection

  def button_to_with_xss_protection(text, *args)
    button_to_without_xss_protection(text.to_s_xss_protected, *args).mark_as_xss_protected
  end
  alias_method_chain :button_to, :xss_protection
end

module ActionView::Helpers::FormHelper
  mark_helpers_as_xss_protected :text_field, :check_box
end

Version data entries

26 entries across 26 versions & 5 rubygems

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