mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 09:05:13 -07:00
Use early returns rather than large if in Variable#taint_check
This commit is contained in:
+13
-12
@@ -107,20 +107,21 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def taint_check(context, obj)
|
def taint_check(context, obj)
|
||||||
if obj.tainted? && Template.taint_mode != :lax
|
return unless obj.tainted?
|
||||||
@markup =~ QuotedFragment
|
return if Template.taint_mode == :lax
|
||||||
name = Regexp.last_match(0)
|
|
||||||
|
|
||||||
error = TaintedError.new("variable '#{name}' is tainted and was not escaped")
|
@markup =~ QuotedFragment
|
||||||
error.line_number = line_number
|
name = Regexp.last_match(0)
|
||||||
error.template_name = context.template_name
|
|
||||||
|
|
||||||
case Template.taint_mode
|
error = TaintedError.new("variable '#{name}' is tainted and was not escaped")
|
||||||
when :warn
|
error.line_number = line_number
|
||||||
context.warnings << error
|
error.template_name = context.template_name
|
||||||
when :error
|
|
||||||
raise error
|
case Template.taint_mode
|
||||||
end
|
when :warn
|
||||||
|
context.warnings << error
|
||||||
|
when :error
|
||||||
|
raise error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user