Defect #29038
closedThumbnail macro causes attachment file not found and broken filename and link
0%
Description
Wiki's thumbnail macro seemed to break attachment's filename attribute when the attachment has non-blank description.
- case 1
On a wiki page attached an image file with description, and wrote twice thumbnail macros of the image file,
then second thumbnail macro can not show thumbnail image, but file not found error.
Sample error page is as follows:
- case 2
On an issue page attached an image file with description, and wrote one thumbnail macro for the image file, then attached file's filename and link is broken such that filename is shown as filename + description, and file link is same.
Sample page is as follows:
Case 1 is affected to wiki, issue , news, and forum.
Case 2 is affected to issue, forum.
Environment is
Environment: Redmine version 3.4.6.stable Ruby version 2.4.1-p111 (2017-03-22) [x86_64-linux-gnu] Rails version 4.2.8 Environment production Database adapter SQLite
- Redmine trunk has same behavior.
Files
Updated by Toru Takahashi over 6 years ago
in thumbnail macro (lib/redmine/wiki-formatting/macros.rb),
title = options[:title] || attachment.title
this line changes attachment.filename
if attachment has non empty description attribute.
In Attachment::title method,
def title title = filename.to_s if description.present? title << " (#{description})" end title end
filename.to_s returns filename itself, so when attachment has descripton,title << " (#{description})"
changes not only title but filename.
I attached a fix patch for app/models/attachment.rb to deep copy from filename attribute to title attribute to keep filename attribute from modifing title attribute.
This patch is generate under svn r17391 (3.4-stable branch).
Updated by Go MAEDA over 6 years ago
- Target version set to 3.3.9
I have confirmed the issue. Here is a test to catch it.
Index: test/unit/attachment_test.rb
===================================================================
--- test/unit/attachment_test.rb (revision 17424)
+++ test/unit/attachment_test.rb (working copy)
@@ -258,6 +258,7 @@
a = Attachment.new(:filename => "test.png", :description => "Cool image")
assert_equal "test.png (Cool image)", a.title
+ assert_equal "test.png", a.filename
end
def test_new_attachment_should_be_editable_by_author
Failure: AttachmentTest#test_title [test/unit/attachment_test.rb:261]: Expected: "test.png" Actual: "test.png (Cool image)"
Updated by Go MAEDA over 6 years ago
- Category changed from Attachments to Text formatting
- Status changed from New to Resolved
- Assignee set to Go MAEDA
Updated by Go MAEDA over 6 years ago
- Status changed from Resolved to Closed
- Resolution set to Fixed
Committed to the trunk and stable branches. Thank you for your contribution.
Updated by Marius BÄ‚LTEANU almost 6 years ago
- Subject changed from thumbnail macro causes attachment file not found and broken filename and link to Thumbnail macro causes attachment file not found and broken filename and link