check template UTF8 validity before parsing

This commit is contained in:
Michael Go
2024-01-10 18:58:15 +00:00
parent a3c837687e
commit 369a6c55e3
3 changed files with 18 additions and 0 deletions
+12
View File
@@ -337,4 +337,16 @@ class TemplateTest < Minitest::Test
assert_equal("x=2", output)
assert_instance_of(String, output)
end
def test_raises_error_with_invalid_utf8
e = assert_raises(SyntaxError) do
Template.parse(<<~LIQUID)
{% comment %}
\xC0
{% endcomment %}
LIQUID
end
assert_equal('Liquid syntax error: Invalid template encoding', e.message)
end
end