Bring back silencing of errors in blank nodes for backwards compatibility (#1292)

This commit is contained in:
Dylan Thacker-Smith
2020-09-15 10:35:18 -04:00
committed by GitHub
parent fb77921b15
commit 77084930e9
2 changed files with 12 additions and 1 deletions

View File

@@ -77,7 +77,10 @@ module Liquid
raise
rescue ::StandardError => e
line_number = node.is_a?(String) ? nil : node.line_number
output << context.handle_error(e, line_number)
error_message = context.handle_error(e, line_number)
if node.instance_of?(Variable) || !node.blank? # conditional for backwards compatibility
output << error_message
end
end
private def parse_liquid_tag(markup, parse_context)

View File

@@ -261,4 +261,12 @@ class ErrorHandlingTest < Minitest::Test
assert_equal("Argument error:\nLiquid error (product line 1): argument error", page)
assert_equal("product", template.errors.first.template_name)
end
def test_bug_compatible_silencing_of_errors_in_blank_nodes
output = Liquid::Template.parse("{% assign x = 0 %}{% if 1 < '2' %}not blank{% assign x = 3 %}{% endif %}{{ x }}").render
assert_equal("Liquid error: comparison of Integer with String failed0", output)
output = Liquid::Template.parse("{% assign x = 0 %}{% if 1 < '2' %}{% assign x = 3 %}{% endif %}{{ x }}").render
assert_equal("0", output)
end
end