プロジェクト

全般

プロフィール

Vote #76156

完了

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

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Text formatting_26
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
26
version_id:
91
issue_org_id:
19313
author_id:
332
assigned_to_id:
1
comments:
6
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
80
ステータス-->[Closed]

説明

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:

![](café.jpg)   =>   

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>![](café.jpg)</p>"
</pre>
--------------------------------------------------------------------------------
Yes, Redcarpet is not available with jruby, test is now skipped.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリText formatting_26 にセット
  • 対象バージョン2.6.3_91 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0