From b1ee9129e78a592c8fc773b7c04902da1bbfc869 Mon Sep 17 00:00:00 2001 From: Justin Li Date: Tue, 2 Jun 2015 10:56:51 -0400 Subject: [PATCH] Raise SyntaxError if raw tag is unclosed --- lib/liquid/tags/raw.rb | 2 ++ test/integration/tags/raw_tag_test.rb | 4 ++++ test/test_helper.rb | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/liquid/tags/raw.rb b/lib/liquid/tags/raw.rb index b7dd3b3..307f71a 100644 --- a/lib/liquid/tags/raw.rb +++ b/lib/liquid/tags/raw.rb @@ -11,6 +11,8 @@ module Liquid end @body << token unless token.empty? end + + raise SyntaxError.new(@options[:locale].t("errors.syntax.tag_never_closed".freeze, block_name: block_name)) end def render(_context) diff --git a/test/integration/tags/raw_tag_test.rb b/test/integration/tags/raw_tag_test.rb index e50874a..ef3e7a6 100644 --- a/test/integration/tags/raw_tag_test.rb +++ b/test/integration/tags/raw_tag_test.rb @@ -22,4 +22,8 @@ class RawTagTest < Minitest::Test assert_template_result ' test {% raw %} {% endraw %}', '{% raw %} test {% raw %} {% {% endraw %}endraw %}' assert_template_result ' Foobar {{ invalid 1', '{% raw %} Foobar {{ invalid {% endraw %}{{ 1 }}' end + + def test_invalid_raw + assert_match_syntax_error /tag was never closed/, '{% raw } foo {% endraw %}' + end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 901060f..e0f988c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -42,7 +42,7 @@ module Minitest assert_match expected, Template.parse(template).render!(assigns), message end - def assert_match_syntax_error(match, template, registers = {}) + def assert_match_syntax_error(match, template, assigns = {}) exception = assert_raises(Liquid::SyntaxError) { Template.parse(template).render(assigns) }