From b1b89ff0ac854d88bff6409fda784191060b18d3 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 17 Jun 2018 05:57:39 +0000 Subject: [PATCH] "attachment:filename" link syntax would not work if the file name contains "@" (#26507). Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@17393 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/wiki_formatting.rb | 4 ++++ test/helpers/application_helper_test.rb | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 9a2de5cff..412d0f434 100644 --- a/lib/redmine/wiki_formatting.rb +++ b/lib/redmine/wiki_formatting.rb @@ -180,6 +180,10 @@ module Redmine html.gsub!(%r{\buser:(.*?)<\/a>}) do "user:#{$2}" end + # restore attachments links with @ in file name eg. [attachment:image@2x.png] + html.gsub!(%r{\battachment:(.*?)}) do + "attachment:#{$2}" + end html end end diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 437b80018..b90522d81 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -694,6 +694,22 @@ RAW textilizable('attachment:test.txt', :attachments => [a1, a2]) end + def test_attachment_links_to_images_with_email_format_should_not_be_parsed + attachment = Attachment.generate!(:filename => 'image@2x.png') + + with_settings :text_formatting => 'textile' do + raw = "attachment:image@2x.png should not be parsed in image@2x.png" + assert_match %r{

image@2x.png should not be parsed in

}, + textilizable(raw, :attachments => [attachment]) + end + + with_settings :text_formatting => 'markdown' do + raw = "attachment:image@2x.png should not be parsed in image@2x.png" + assert_match %r{

image@2x.png should not be parsed in image@2x.png

} , + textilizable(raw, :attachments => [attachment]) + end + end + def test_wiki_links User.current = User.find_by_login('jsmith') russian_eacape = CGI.escape(@russian_test)