@@ -634,7 +634,7 module ApplicationHelper | |||||
634 | text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m| |
|
634 | text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m| | |
635 | filename, ext, alt, alttext = $1.downcase, $2, $3, $4 |
|
635 | filename, ext, alt, alttext = $1.downcase, $2, $3, $4 | |
636 | # search for the picture in attachments |
|
636 | # search for the picture in attachments | |
637 | if found = Attachment.latest_attach(attachments, filename) |
|
637 | if found = Attachment.latest_attach(attachments, CGI.unescape(filename)) | |
638 | image_url = download_named_attachment_url(found, found.filename, :only_path => only_path) |
|
638 | image_url = download_named_attachment_url(found, found.filename, :only_path => only_path) | |
639 | desc = found.description.to_s.gsub('"', '') |
|
639 | desc = found.description.to_s.gsub('"', '') | |
640 | if !desc.blank? && alttext.blank? |
|
640 | if !desc.blank? && alttext.blank? |
@@ -151,6 +151,22 RAW | |||||
151 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) } |
|
151 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) } | |
152 | end |
|
152 | end | |
153 |
|
153 | |||
|
154 | def test_attached_images_with_textile_and_non_ascii_filename | |||
|
155 | attachment = Attachment.generate!(:filename => 'café.jpg') | |||
|
156 | with_settings :text_formatting => 'textile' do | |||
|
157 | assert_include %(<img src="/attachments/download/#{attachment.id}/caf%C3%A9.jpg" alt="" />), | |||
|
158 | textilizable("!café.jpg!)", :attachments => [attachment]) | |||
|
159 | end | |||
|
160 | end | |||
|
161 | ||||
|
162 | def test_attached_images_with_markdown_and_non_ascii_filename | |||
|
163 | attachment = Attachment.generate!(:filename => 'café.jpg') | |||
|
164 | with_settings :text_formatting => 'markdown' do | |||
|
165 | assert_include %(<img src="/attachments/download/#{attachment.id}/caf%C3%A9.jpg" alt="">), | |||
|
166 | textilizable("", :attachments => [attachment]) | |||
|
167 | end | |||
|
168 | end | |||
|
169 | ||||
154 | def test_attached_images_filename_extension |
|
170 | def test_attached_images_filename_extension | |
155 | set_tmp_attachments_directory |
|
171 | set_tmp_attachments_directory | |
156 | a1 = Attachment.new( |
|
172 | a1 = Attachment.new( |
General Comments 0
You need to be logged in to leave comments.
Login now