From d889127d583c85e74045ce15279c89e5f83f735b Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Wed, 24 Feb 2021 09:49:29 -0500 Subject: [PATCH] Require a space after the inline comment tag name (i.e. after `#`) --- lib/liquid/block_body.rb | 4 ++-- test/integration/tags/inline_comment_test.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/liquid/block_body.rb b/lib/liquid/block_body.rb index a9c002c93..69a29c5e5 100644 --- a/lib/liquid/block_body.rb +++ b/lib/liquid/block_body.rb @@ -4,8 +4,8 @@ module Liquid class BlockBody - LiquidTagToken = /\A\s*(\w+|#)\s*(.*?)\z/o - FullToken = /\A#{TagStart}#{WhitespaceControl}?(\s*)(\w+|#)(\s*)(.*?)#{WhitespaceControl}?#{TagEnd}\z/om + LiquidTagToken = /\A\s*([\w#]+)\s*(.*?)\z/o + FullToken = /\A#{TagStart}#{WhitespaceControl}?(\s*)([\w#]+)(\s*)(.*?)#{WhitespaceControl}?#{TagEnd}\z/om ContentOfVariable = /\A#{VariableStart}#{WhitespaceControl}?(.*?)#{WhitespaceControl}?#{VariableEnd}\z/om WhitespaceOrNothing = /\A\s*\z/ TAGSTART = "{%" diff --git a/test/integration/tags/inline_comment_test.rb b/test/integration/tags/inline_comment_test.rb index 55db2273d..768c4c69e 100644 --- a/test/integration/tags/inline_comment_test.rb +++ b/test/integration/tags/inline_comment_test.rb @@ -21,7 +21,7 @@ def test_inside_liquid_tag end def test_no_space_after_hash_symbol - assert_template_result('', '{% #immediate text %}') - assert_template_result('', '{% liquid #immediate text %}') + assert_match_syntax_error(/Unknown tag '#immediate'/, '{% #immediate text %}') + assert_match_syntax_error(/Unknown tag '#immediate'/, '{% liquid #immediate text %}') end end