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

Also available in: Atom PDF