From: Jean-Philippe Lang Date: Sat, 14 Mar 2015 08:39:24 +0000 (+0000) Subject: Attached inline images with non-ascii file name can not be seen when text formatting... X-Git-Tag: 3.1.0~205 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5da48d929367df231df8dde382bdb8e5eb7e1540;p=redmine.git Attached inline images with non-ascii file name can not be seen when text formatting is Makdown (#19313). Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@14080 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 74f8ab828..c58873c20 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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? diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 13a34064f..a4c588676 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -151,6 +151,22 @@ RAW to_test.each { |text, result| assert_equal "

#{result}

", 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 %(), + 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 %(), + textilizable("![](café.jpg)", :attachments => [attachment]) + end + end + def test_attached_images_filename_extension set_tmp_attachments_directory a1 = Attachment.new(