diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 9a2de5c..412d0f4 100755 --- 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 ca2407d..425885e 100755 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -692,6 +692,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)