From afee90b3f719cf12f0e465aaa68ecd448f9cd2f4 Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Mon, 17 Mar 2025 09:58:30 -0600 Subject: [PATCH] Strict parsing only on Liquid::Variable --- lib/liquid/variable.rb | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/lib/liquid/variable.rb b/lib/liquid/variable.rb index 209570654..ea6942aa6 100644 --- a/lib/liquid/variable.rb +++ b/lib/liquid/variable.rb @@ -30,7 +30,7 @@ def initialize(markup, parse_context) @parse_context = parse_context @line_number = parse_context.line_number - strict_parse_with_error_mode_fallback(markup) + strict_parse_with_error_context(markup) end def raw @@ -41,22 +41,12 @@ def markup_context(markup) "in \"{{#{markup}}}\"" end - def lax_parse(markup) - @filters = [] - return unless markup =~ MarkupWithQuotedFragment - - name_markup = Regexp.last_match(1) - filter_markup = Regexp.last_match(2) - @name = parse_context.parse_expression(name_markup) - if filter_markup =~ FilterMarkupRegex - filters = Regexp.last_match(1).scan(FilterParser) - filters.each do |f| - next unless f =~ /\w+/ - filtername = Regexp.last_match(0) - filterargs = f.scan(FilterArgsRegex).flatten - @filters << parse_filter_expressions(filtername, filterargs) - end - end + def strict_parse_with_error_context(markup) + strict_parse(markup) + rescue SyntaxError => e + e.line_number = line_number + e.markup_context = markup_context(markup) + raise e end def strict_parse(markup)