Attempt to strict parse variables before lax parsing in lax error mode (#1338)

This commit is contained in:
Dylan Thacker-Smith
2020-10-28 10:37:00 -04:00
committed by GitHub
parent 1d63d5db5f
commit 7754d5aef5
4 changed files with 23 additions and 1 deletions

View File

@@ -2,6 +2,18 @@
module Liquid
module ParserSwitching
def strict_parse_with_error_mode_fallback(markup)
strict_parse_with_error_context(markup)
rescue SyntaxError => e
case parse_context.error_mode
when :strict
raise
when :warn
parse_context.warnings << e
end
lax_parse(markup)
end
def parse_with_selected_parser(markup)
case parse_context.error_mode
when :strict then strict_parse_with_error_context(markup)

View File

@@ -30,7 +30,7 @@ module Liquid
@parse_context = parse_context
@line_number = parse_context.line_number
parse_with_selected_parser(markup)
strict_parse_with_error_mode_fallback(markup)
end
def raw