Commit d7ebffb7 authored by Holger Just's avatar Holger Just

[#795] Generate error flash on Liquid syntax error

parent 61a65d46
......@@ -295,7 +295,7 @@ module ApplicationHelper
projects.each do |project|
s << "<label>#{ check_box_tag name, project.id, false } #{h project}</label>\n"
end
s
s
end
# Truncates and returns the string as a single line
......@@ -487,14 +487,17 @@ module ApplicationHelper
Rails.logger.debug msg
end
rescue Liquid::SyntaxError => exception
msg = "[Liquid Syntax Error] #{exception.message}"
if Rails.logger && Rails.logger.debug?
msg = "[Liquid Syntax Error] #{exception.message}\n:\n#{exception.backtrace.join("\n")}"
msg << "\n\n"
Rails.logger.debug msg
log_msg = "#{msg}\n"
log_msg << exception.backtrace.collect{ |str| " #{str}" }.join("\n")
log_msg << "\n\n"
Rails.logger.debug log_msg
end
# Skip Liquid if there is a syntax error
text = h(input_text)
text = content_tag(:div, msg, :class => "flash error")
text << h(input_text)
end
@parsed_headings = []
......
......@@ -229,5 +229,13 @@ class ChiliProject::LiquidTest < ActionView::TestCase
formatted = textilizable(text)
assert_match '&lt;script&gt;alert(&quot;Hello&quot;)&lt;/script&gt;', formatted
end
should "have an error flash" do
text = "{% --- something invalid %}\n"
formatted = textilizable(text)
assert_match /flash error/, formatted
assert_match '[Liquid Syntax Error]', formatted
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment