From 66084c8f9753a9b3646a754d933b98965d5b968b Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 24 May 2014 16:40:29 +0000 Subject: [PATCH] Merged r13122 (#16781). git-svn-id: http://svn.redmine.org/redmine/branches/2.5-stable@13166 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/wiki_formatting/markdown/formatter.rb | 2 +- .../redmine/wiki_formatting/markdown_formatter.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/redmine/wiki_formatting/markdown/formatter.rb b/lib/redmine/wiki_formatting/markdown/formatter.rb index 22c22c82b..a55845147 100644 --- a/lib/redmine/wiki_formatting/markdown/formatter.rb +++ b/lib/redmine/wiki_formatting/markdown/formatter.rb @@ -28,7 +28,7 @@ module Redmine unless link && link.starts_with?('/') css = 'external' 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 def block_code(code, language) diff --git a/test/unit/lib/redmine/wiki_formatting/markdown_formatter.rb b/test/unit/lib/redmine/wiki_formatting/markdown_formatter.rb index 98a55eb5f..811f28133 100644 --- a/test/unit/lib/redmine/wiki_formatting/markdown_formatter.rb +++ b/test/unit/lib/redmine/wiki_formatting/markdown_formatter.rb @@ -24,6 +24,18 @@ class Redmine::WikiFormatting::MarkdownFormatterTest < ActionView::TestCase @formatter = Redmine::WikiFormatting::Markdown::Formatter 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 assert_equal "

foo

", @formatter.new("**foo**").to_html.strip end -- 2.39.5