summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-03-14 14:59:13 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-03-14 14:59:13 +0000
commitae1e3980b067aa097eda266932afdf1271c09538 (patch)
tree517c1844c2704b322534d006a092059103e40808
parent9da5692aee52ca8b88ff5dea6aa7f2fe9ddb1110 (diff)
downloadredmine-ae1e3980b067aa097eda266932afdf1271c09538.tar.gz
redmine-ae1e3980b067aa097eda266932afdf1271c09538.zip
Merged r14080 (#19313).
git-svn-id: http://svn.redmine.org/redmine/branches/2.6-stable@14089 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--test/unit/helpers/application_helper_test.rb16
2 files changed, 17 insertions, 1 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 3ef023278..c3291db3f 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -654,7 +654,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_path(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 2ace709ee..a551dcf90 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -157,6 +157,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(