[#795] Generate error flash on Liquid syntax error
This commit is contained in:
parent
61a65d4624
commit
d7ebffb7ad
|
@ -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 '<script>alert("Hello")</script>', 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
|
||||
|
|
Loading…
Reference in New Issue