From 35570d4ee092b7cf21f54939794329d0dc245b25 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Fri, 6 Nov 2020 14:16:40 -0500 Subject: [PATCH] Fix regex for matching endraw tags --- lib/liquid/tags/raw.rb | 4 ++-- test/integration/tags/raw_tag_test.rb | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/liquid/tags/raw.rb b/lib/liquid/tags/raw.rb index 3a5b990..896945c 100644 --- a/lib/liquid/tags/raw.rb +++ b/lib/liquid/tags/raw.rb @@ -3,7 +3,7 @@ module Liquid class Raw < Block Syntax = /\A\s*\z/ - FullTokenPossiblyInvalid = /\A(.*)#{TagStart}\s*(\w+)\s*(.*)?#{TagEnd}\z/om + EndRawTag = /\A(.*)#{TagStart}\s*endraw.*?#{TagEnd}\z/om def initialize(tag_name, markup, parse_context) super @@ -14,7 +14,7 @@ module Liquid def parse(tokens) @body = +'' while (token = tokens.shift) - if token =~ FullTokenPossiblyInvalid && block_delimiter == Regexp.last_match(2) + if token =~ EndRawTag @body << Regexp.last_match(1) if Regexp.last_match(1) != "" return end diff --git a/test/integration/tags/raw_tag_test.rb b/test/integration/tags/raw_tag_test.rb index 7ac0b09..7c5ea48 100644 --- a/test/integration/tags/raw_tag_test.rb +++ b/test/integration/tags/raw_tag_test.rb @@ -12,6 +12,8 @@ class RawTagTest < Minitest::Test def test_output_in_raw assert_template_result('{{ test }}', '{% raw %}{{ test }}{% endraw %}') + assert_template_result('test', '{% raw %}test{% endraw{% f %}') + assert_template_result('test', '{% raw %}test{% endraw{% |f %}') end def test_open_tag_in_raw