[#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
|
Rails.logger.debug msg
|
||||||
end
|
end
|
||||||
rescue Liquid::SyntaxError => exception
|
rescue Liquid::SyntaxError => exception
|
||||||
|
msg = "[Liquid Syntax Error] #{exception.message}"
|
||||||
if Rails.logger && Rails.logger.debug?
|
if Rails.logger && Rails.logger.debug?
|
||||||
msg = "[Liquid Syntax Error] #{exception.message}\n:\n#{exception.backtrace.join("\n")}"
|
log_msg = "#{msg}\n"
|
||||||
msg << "\n\n"
|
log_msg << exception.backtrace.collect{ |str| " #{str}" }.join("\n")
|
||||||
Rails.logger.debug msg
|
log_msg << "\n\n"
|
||||||
|
Rails.logger.debug log_msg
|
||||||
end
|
end
|
||||||
|
|
||||||
# Skip Liquid if there is a syntax error
|
# 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
|
end
|
||||||
|
|
||||||
@parsed_headings = []
|
@parsed_headings = []
|
||||||
|
@ -229,5 +229,13 @@ class ChiliProject::LiquidTest < ActionView::TestCase
|
|||||||
formatted = textilizable(text)
|
formatted = textilizable(text)
|
||||||
assert_match '<script>alert("Hello")</script>', formatted
|
assert_match '<script>alert("Hello")</script>', formatted
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user