]> source.dussan.org Git - redmine.git/commitdiff
Merged r14080 (#19313).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 14 Mar 2015 14:57:18 +0000 (14:57 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 14 Mar 2015 14:57:18 +0000 (14:57 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.0-stable@14088 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/unit/helpers/application_helper_test.rb

index 74f8ab828a28537e32531c587dc8a764d7e9f2eb..c58873c207917d79e4ed154e228932412e1cf20f 100644 (file)
@@ -634,7 +634,7 @@ module ApplicationHelper
       text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
         filename, ext, alt, alttext = $1.downcase, $2, $3, $4
         # search for the picture in attachments
-        if found = Attachment.latest_attach(attachments, filename)
+        if found = Attachment.latest_attach(attachments, CGI.unescape(filename))
           image_url = download_named_attachment_url(found, found.filename, :only_path => only_path)
           desc = found.description.to_s.gsub('"', '')
           if !desc.blank? && alttext.blank?
index 13a34064fa5b1b168791b92dc255e81c79523244..a4c588676f9b88f5bdd061a4a86f87746171db44 100644 (file)
@@ -151,6 +151,22 @@ RAW
     to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) }
   end
 
+  def test_attached_images_with_textile_and_non_ascii_filename
+    attachment = Attachment.generate!(:filename => 'café.jpg')
+    with_settings :text_formatting => 'textile' do
+      assert_include %(<img src="/attachments/download/#{attachment.id}/caf%C3%A9.jpg" alt="" />),
+        textilizable("!café.jpg!)", :attachments => [attachment])
+    end
+  end
+
+  def test_attached_images_with_markdown_and_non_ascii_filename
+    attachment = Attachment.generate!(:filename => 'café.jpg')
+    with_settings :text_formatting => 'markdown' do
+      assert_include %(<img src="/attachments/download/#{attachment.id}/caf%C3%A9.jpg" alt="">),
+        textilizable("![](café.jpg)", :attachments => [attachment])
+    end
+  end
+
   def test_attached_images_filename_extension
     set_tmp_attachments_directory
     a1 = Attachment.new(