]> source.dussan.org Git - redmine.git/commitdiff
"attachment:filename" link syntax would not work if the file name contains "@" (...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 17 Jun 2018 05:57:39 +0000 (05:57 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 17 Jun 2018 05:57:39 +0000 (05:57 +0000)
Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@17393 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/wiki_formatting.rb
test/helpers/application_helper_test.rb

index 9a2de5cffbdb8fa6fe24ac2ff661f4187688cc7f..412d0f434cde0ed508d8c44cc02b6175bd98f024 100644 (file)
@@ -180,6 +180,10 @@ module Redmine
         html.gsub!(%r{\buser:<a(\sclass="email")? href="mailto:(.*?)">(.*?)<\/a>}) do
           "user:#{$2}"
         end
+        # restore attachments links with @ in file name eg. [attachment:image@2x.png]
+        html.gsub!(%r{\battachment:<a(\sclass="email")? href="mailto:(.*?)">(.*?)</a>}) do
+          "attachment:#{$2}"
+        end
         html
       end
     end
index 437b80018556afcfda878db2fd5c10abb5d248cc..b90522d81525be79719c698877a9007d6feb9835 100644 (file)
@@ -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{<p><a class="attachment" href="/attachments/#{attachment.id}/image@2x.png">image@2x.png</a> should not be parsed in <a class="email" href="mailto:image@2x.png">image@2x.png</a></p>},
+        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{<p><a class="attachment" href="/attachments/#{attachment.id}/image@2x.png">image@2x.png</a> should not be parsed in <a href="mailto:image@2x.png">image@2x.png</a></p>} ,
+        textilizable(raw, :attachments => [attachment])
+    end
+  end
+
   def test_wiki_links
     User.current = User.find_by_login('jsmith')
     russian_eacape = CGI.escape(@russian_test)