Project

General

Profile

Actions

Defect #19313

closed

Attached inline images with non-ascii file name can not be seen when text formatting is Markdown

Added by Go MAEDA over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Category:
Text formatting
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

If you attatch an image with non-ascii name such as "café.jpg" to an issue and make an attempt to display as inline image, you will fail if text formatting is Markdown.

The cause of the defect is that Markdown formatter generates escaped file name. ApplicationController#parse_inline_attachments (source:trunk/app/helpers/application_helper.rb@14003#L637) expects a file name without escaping.

Textile:

!café.jpg!   =>   <img src="café.jpg" alt="" />

Markdown:

![](café.jpg)   =>   <img src="caf%C3%A9.jpg" alt="">

Quick workaround is the following:

Index: app/helpers/application_helper.rb
===================================================================
--- app/helpers/application_helper.rb    (revision 14066)
+++ app/helpers/application_helper.rb    (working copy)
@@ -634,7 +634,7 @@
       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?
Actions #1

Updated by Jean-Philippe Lang over 9 years ago

  • Target version set to 3.0.1
Actions #2

Updated by Jean-Philippe Lang over 9 years ago

  • Status changed from New to Resolved
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

Fix committed in r14080 with tests, thanks.

Actions #3

Updated by Jean-Philippe Lang over 9 years ago

  • Status changed from Resolved to Closed
  • Target version changed from 3.0.1 to 2.6.3
Actions #4

Updated by Toshi MARUYAMA over 9 years ago

  • Status changed from Closed to Reopened

jruby on 2.6-stable tests fail.
http://www.redmine.org/builds/logs/build_2.6-stable_mysql_jruby-1.7.6_41.html

  1) Failure:
test_attached_images_with_markdown_and_non_ascii_filename(ApplicationHelperTest)
[/var/lib/jenkins/workspace/2.6-stable/DATABASE_ADAPTER/mysql/RUBY_VER/jruby-1.7.6/test/unit/helpers/application_helper_test.rb:171]:
"<img src="/attachments/download/25/caf%C3%A9.jpg" alt="">" not found in "<p>![](café.jpg)</p>" 

Actions #5

Updated by Jean-Philippe Lang over 9 years ago

  • Status changed from Reopened to Closed

Yes, Redcarpet is not available with jruby, test is now skipped.

Actions #6

Updated by Go MAEDA over 9 years ago

  • Subject changed from Attached inline images with non-ascii file name can not be seen when text formatting is Makdown to Attached inline images with non-ascii file name can not be seen when text formatting is Markdown
Actions

Also available in: Atom PDF