Crash in markdown formatter causes ruby process to end (#16781).

Patch by Jens Krämer.

git-svn-id: http://svn.redmine.org/redmine/trunk@13122 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2014-05-02 06:57:29 +00:00
parent 9875ed9954
commit bcc5ac38f3
2 changed files with 13 additions and 1 deletions

View File

@ -28,7 +28,7 @@ module Redmine
unless link && link.starts_with?('/') unless link && link.starts_with?('/')
css = 'external' css = 'external'
end end
content_tag('a', content.html_safe, :href => link, :title => title, :class => css) content_tag('a', content.to_s.html_safe, :href => link, :title => title, :class => css)
end end
def block_code(code, language) def block_code(code, language)

View File

@ -24,6 +24,18 @@ class Redmine::WikiFormatting::MarkdownFormatterTest < ActionView::TestCase
@formatter = Redmine::WikiFormatting::Markdown::Formatter @formatter = Redmine::WikiFormatting::Markdown::Formatter
end end
def test_syntax_error_in_image_reference_should_not_raise_exception
assert @formatter.new("!>[](foo.png)").to_html
end
# re-using the formatter after getting above error crashes the
# ruby interpreter. This seems to be related to
# https://github.com/vmg/redcarpet/issues/318
def test_should_not_crash_redcarpet_after_syntax_error
@formatter.new("!>[](foo.png)").to_html rescue nil
assert @formatter.new("![](foo.png)").to_html.present?
end
def test_inline_style def test_inline_style
assert_equal "<p><strong>foo</strong></p>", @formatter.new("**foo**").to_html.strip assert_equal "<p><strong>foo</strong></p>", @formatter.new("**foo**").to_html.strip
end end