Dont Raise Error For Incorrect Liquid Tags (#5089) [deploy]

This commit is contained in:
Molly Struve 2019-12-18 11:23:39 -06:00 committed by GitHub
parent 9ad95cb6f9
commit b5614a34e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View file

@ -18,10 +18,10 @@ class MarkdownParser
sanitized_content = sanitize_rendered_markdown(html)
begin
parsed_liquid = Liquid::Template.parse(sanitized_content)
rescue StandardError => e
raise StandardError, e.message
html = markdown.render(parsed_liquid.render)
rescue Liquid::SyntaxError => e
html = e.message
end
html = markdown.render(parsed_liquid.render)
html = remove_nested_linebreak_in_list(html)
html = prefix_all_images(html)
html = wrap_all_images_in_links(html)
@ -97,6 +97,8 @@ class MarkdownParser
tags << node.class if node.class.superclass.to_s == LiquidTagBase.to_s
end
tags.uniq
rescue Liquid::SyntaxError
[]
end
def prefix_all_images(html, width = 880)

View file

@ -195,9 +195,9 @@ RSpec.describe MarkdownParser, type: :labor do
end
context "when provided with liquid tags" do
it "raises error if liquid tag was used incorrectly" do
it "does not raises error if liquid tag was used incorrectly" do
bad_ltag = "{% #{random_word} %}"
expect { generate_and_parse_markdown(bad_ltag) }.to raise_error(StandardError)
expect { generate_and_parse_markdown(bad_ltag) }.not_to raise_error(StandardError)
end
end