Use early returns rather than large if in Variable#taint_check

This commit is contained in:
Dylan Thacker-Smith
2015-07-07 15:56:03 -04:00
parent 80b6ac3bc7
commit c4c398174b
+13 -12
View File
@@ -107,20 +107,21 @@ module Liquid
end
def taint_check(context, obj)
if obj.tainted? && Template.taint_mode != :lax
@markup =~ QuotedFragment
name = Regexp.last_match(0)
return unless obj.tainted?
return if Template.taint_mode == :lax
error = TaintedError.new("variable '#{name}' is tainted and was not escaped")
error.line_number = line_number
error.template_name = context.template_name
@markup =~ QuotedFragment
name = Regexp.last_match(0)
case Template.taint_mode
when :warn
context.warnings << error
when :error
raise error
end
error = TaintedError.new("variable '#{name}' is tainted and was not escaped")
error.line_number = line_number
error.template_name = context.template_name
case Template.taint_mode
when :warn
context.warnings << error
when :error
raise error
end
end
end