diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index d00636d4c..1eef95100 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -774,7 +774,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)
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index a524c91b8..74acae4b0 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -156,20 +156,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 %(
),
- textilizable("!café.jpg!)", :attachments => [attachment])
+ to_test.each do |filename, result|
+ attachment = Attachment.generate!(:filename => filename)
+ assert_include %(
), 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 %(
),
- textilizable("", :attachments => [attachment])
+ to_test.each do |filename, result|
+ attachment = Attachment.generate!(:filename => filename)
+ assert_include %(
), textilizable("", :attachments => [attachment])
+ end
end
end