Compare commits

...

1 Commits

Author SHA1 Message Date
Peter Zhu
35570d4ee0 Fix regex for matching endraw tags 2020-11-06 14:54:58 -05:00
2 changed files with 4 additions and 2 deletions

View File

@@ -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

View File

@@ -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