]> source.dussan.org Git - redmine.git/commitdiff
Merged r18057 and r18058 from trunk to 4.0-stable (#30441).
authorGo MAEDA <maeda@farend.jp>
Thu, 18 Apr 2019 14:31:58 +0000 (14:31 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 18 Apr 2019 14:31:58 +0000 (14:31 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/4.0-stable@18060 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 8fa56ac55bfc21783aa49a9291cc52af8592426d..542c2e800ffb2220a36144293469d25ecefc5256 100644 (file)
@@ -760,7 +760,7 @@ module ApplicationHelper
     attachments += obj.attachments if obj.respond_to?(:attachments)
     if attachments.present?
       text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
-        filename, ext, alt, alttext = $1.downcase, $2, $3, $4
+        filename, ext, alt, alttext = $1, $2, $3, $4
         # search for the picture in attachments
         if found = Attachment.latest_attach(attachments, CGI.unescape(filename))
           image_url = download_named_attachment_url(found, found.filename, :only_path => only_path)
index 26ca772b719e64d1b97a9a61e87867fe016e8641..70f77ec4277a62e977068ee367530e43b58348de 100644 (file)
@@ -154,20 +154,30 @@ RAW
   end
 
   def test_attached_images_with_textile_and_non_ascii_filename
-    attachment = Attachment.generate!(:filename => 'café.jpg')
+    to_test = {
+      'CAFÉ.JPG' => 'CAF%C3%89.JPG',
+      'crème.jpg' => 'cr%C3%A8me.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])
+      to_test.each do |filename, result|
+        attachment = Attachment.generate!(:filename => filename)
+        assert_include %(<img src="/attachments/download/#{attachment.id}/#{result}" alt="" />), textilizable("!#{filename}!", :attachments => [attachment])
+      end
     end
   end
 
   def test_attached_images_with_markdown_and_non_ascii_filename
     skip unless Object.const_defined?(:Redcarpet)
 
-    attachment = Attachment.generate!(:filename => 'café.jpg')
+    to_test = {
+      'CAFÉ.JPG' => 'CAF%C3%89.JPG',
+      'crème.jpg' => 'cr%C3%A8me.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])
+      to_test.each do |filename, result|
+        attachment = Attachment.generate!(:filename => filename)
+        assert_include %(<img src="/attachments/download/#{attachment.id}/#{result}" alt="" />), textilizable("![](#{filename})", :attachments => [attachment])
+      end
     end
   end