diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 27930ac94..552a4cde1 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -357,16 +357,15 @@ module ApplicationHelper
attachments = attachments.sort_by(&:created_on).reverse
text = text.gsub(/!((\<|\=|\>)?(\([^\)]+\))?(\[[^\]]+\])?(\{[^\}]+\})?)(\S+\.(bmp|gif|jpg|jpeg|png))!/i) do |m|
style = $1
- filename = $6
- rf = Regexp.new(Regexp.escape(filename), Regexp::IGNORECASE)
+ filename = $6.downcase
# search for the picture in attachments
- if found = attachments.detect { |att| att.filename =~ rf }
+ if found = attachments.detect { |att| att.filename.downcase == filename }
image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found
desc = found.description.to_s.gsub(/^([^\(\)]*).*$/, "\\1")
alt = desc.blank? ? nil : "(#{desc})"
"!#{style}#{image_url}#{alt}!"
else
- "!#{style}#{filename}!"
+ m
end
end
end
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index 26ecf50b1..cafa92ef4 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -89,7 +89,9 @@ class ApplicationHelperTest < HelperTestCase
def test_attached_images
to_test = {
'Inline image: !logo.gif!' => 'Inline image: ',
- 'Inline image: !logo.GIF!' => 'Inline image:
'
+ 'Inline image: !logo.GIF!' => 'Inline image:
',
+ 'No match: !ogo.gif!' => 'No match:
',
+ 'No match: !ogo.GIF!' => 'No match:
'
}
attachments = Attachment.find(:all)
to_test.each { |text, result| assert_equal "
#{result}
", textilizable(text, :attachments => attachments) }