Compare commits

..

3 Commits

Author SHA1 Message Date
Peter Zhu
35570d4ee0 Fix regex for matching endraw tags 2020-11-06 14:54:58 -05:00
Peter Zhu
c7c21e88f0 Merge pull request #1344 from Shopify/pz-test-space-in-dot
Test space between dot for attributes
2020-11-06 10:10:08 -05:00
Peter Zhu
a89371b0b9 Test space between dot 2020-11-05 15:39:44 -05:00
5 changed files with 7 additions and 17 deletions

View File

@@ -22,6 +22,6 @@ group :test do
gem 'rubocop-performance', require: false
platform :mri, :truffleruby do
gem 'liquid-c', github: 'Shopify/liquid-c', ref: 'pz-fix-invalid-float'
gem 'liquid-c', github: 'Shopify/liquid-c', ref: 'master'
end
end

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

@@ -131,16 +131,4 @@ class ParsingQuirksTest < Minitest::Test
def test_contains_in_id
assert_template_result(' YES ', '{% if containsallshipments == true %} YES {% endif %}', 'containsallshipments' => true)
end
def test_invalid_float_with_no_leading_integer
with_error_mode(:lax) do
assert_template_result("", "{{ -.1 }}")
assert_template_result("", "{{ .1 }}")
end
with_error_mode(:strict) do
assert_raises(SyntaxError) { Template.parse("{{ -.1 }}") }
assert_raises(SyntaxError) { Template.parse("{{ .1 }}") }
end
end
end # ParsingQuirksTest

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

View File

@@ -42,8 +42,8 @@ class VariableTest < Minitest::Test
end
def test_hash_scoping
template = Template.parse(%({{ test.test }}))
assert_equal('worked', template.render!('test' => { 'test' => 'worked' }))
assert_template_result('worked', "{{ test.test }}", 'test' => { 'test' => 'worked' })
assert_template_result('worked', "{{ test . test }}", 'test' => { 'test' => 'worked' })
end
def test_false_renders_as_false