Vote #76156
完了Attached inline images with non-ascii file name can not be seen when text formatting is Markdown
0%
説明
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! =>![]()
Markdown:
 =>![]()
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?
journals
--------------------------------------------------------------------------------
Fix committed in r14080 with tests, thanks.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
jruby on 2.6-stable tests fail.
http://www.redmine.org/builds/logs/build_2.6-stable_mysql_jruby-1.7.6_41.html
<pre>
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></p>"
</pre>
--------------------------------------------------------------------------------
Yes, Redcarpet is not available with jruby, test is now skipped.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------