Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
abedra committed Dec 30, 2012
1 parent a703bb4 commit 5d26dea
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/safe_erb.rb
Expand Up @@ -7,7 +7,7 @@ class ActionController::Base
# but it is not set in Mongrel and also functional / integration testing # but it is not set in Mongrel and also functional / integration testing
# so we'll set it anyways in the filter # so we'll set it anyways in the filter
before_filter :taint_request before_filter :taint_request

def render_with_checking_tainted(*args, &blk) def render_with_checking_tainted(*args, &blk)
if @skip_checking_tainted if @skip_checking_tainted
render_without_checking_tainted(*args, &blk) render_without_checking_tainted(*args, &blk)
Expand All @@ -21,7 +21,7 @@ def render_with_checking_tainted(*args, &blk)
alias_method_chain :render, :checking_tainted alias_method_chain :render, :checking_tainted


private private

def taint_hash(hash) def taint_hash(hash)
hash.each do |k, v| hash.each do |k, v|
case v case v
Expand All @@ -32,7 +32,7 @@ def taint_hash(hash)
end end
end end
end end

def taint_request def taint_request
taint_hash(params) taint_hash(params)
cookies.each do |k, v| cookies.each do |k, v|
Expand All @@ -51,7 +51,7 @@ def concat_unless_tainted(str)
class ERB class ERB
cattr_accessor :check_tainted cattr_accessor :check_tainted
alias_method :original_set_eoutvar, :set_eoutvar alias_method :original_set_eoutvar, :set_eoutvar

def self.with_checking_tainted(&block) def self.with_checking_tainted(&block)
# not thread safe # not thread safe
ERB.check_tainted = true ERB.check_tainted = true
Expand All @@ -61,7 +61,7 @@ def self.with_checking_tainted(&block)
ERB.check_tainted = false ERB.check_tainted = false
end end
end end

def set_eoutvar(compiler, eoutvar = '_erbout') def set_eoutvar(compiler, eoutvar = '_erbout')
original_set_eoutvar(compiler, eoutvar) original_set_eoutvar(compiler, eoutvar)
if check_tainted if check_tainted
Expand All @@ -72,18 +72,18 @@ def set_eoutvar(compiler, eoutvar = '_erbout')
end end
end end
end end

module Util module Util
alias_method :html_escape_without_untaint, :html_escape alias_method :html_escape_without_untaint, :html_escape

def html_escape(s) def html_escape(s)
h = html_escape_without_untaint(s) h = html_escape_without_untaint(s)
h.untaint h.untaint
h h
end end

alias_method :h, :html_escape alias_method :h, :html_escape

module_function :h module_function :h
module_function :html_escape module_function :html_escape
module_function :html_escape_without_untaint module_function :html_escape_without_untaint
Expand All @@ -106,7 +106,7 @@ module TagHelper
def escape_once_with_untaint(html) def escape_once_with_untaint(html)
escape_once_without_untaint(html).untaint escape_once_without_untaint(html).untaint
end end

alias_method_chain :escape_once, :untaint alias_method_chain :escape_once, :untaint
end end
end end
Expand Down

0 comments on commit 5d26dea

Please sign in to comment.