https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292018-06-17T15:29:07ZRedmineRedmine - Defect #29038: Thumbnail macro causes attachment file not found and broken filename and link https://www.redmine.org/issues/29038?journal_id=856072018-06-17T15:29:07ZToru Takahashi
<ul><li><strong>File</strong> <a href="/attachments/20886">attachment_title_dup_from_filename.diff</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/20886/attachment_title_dup_from_filename.diff">attachment_title_dup_from_filename.diff</a> added</li></ul><p>in thumbnail macro (lib/redmine/wiki-formatting/macros.rb),<br /><pre>
title = options[:title] || attachment.title
</pre></p>
<p>this line changes <code>attachment.filename</code> if attachment has non empty description attribute.</p>
<p>In Attachment::title method,<br /><pre>
def title
title = filename.to_s
if description.present?
title << " (#{description})"
end
title
end
</pre></p>
<p>filename.to_s returns filename itself, so when attachment has descripton,<br /><code>title << " (#{description})"</code> changes not only title but filename.</p>
<p>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.<br />This patch is generate under svn <a class="changeset" title="Merged r17390 from trunk to 3.4-stable (#28946)." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/17391">r17391</a> (3.4-stable branch).</p> Redmine - Defect #29038: Thumbnail macro causes attachment file not found and broken filename and link https://www.redmine.org/issues/29038?journal_id=859422018-06-30T06:30:37ZGo MAEDA
<ul><li><strong>Target version</strong> set to <i>3.3.9</i></li></ul><p>I have confirmed the issue. Here is a test to catch it.</p>
<pre><code class="diff syntaxhl"><span class="gh">Index: test/unit/attachment_test.rb
===================================================================
</span><span class="gd">--- test/unit/attachment_test.rb (revision 17424)
</span><span class="gi">+++ test/unit/attachment_test.rb (working copy)
</span><span class="p">@@ -258,6 +258,7 @@</span>
a = Attachment.new(:filename => "test.png", :description => "Cool image")
assert_equal "test.png (Cool image)", a.title
<span class="gi">+ assert_equal "test.png", a.filename
</span> end
def test_new_attachment_should_be_editable_by_author
</code></pre>
<pre>
Failure:
AttachmentTest#test_title [test/unit/attachment_test.rb:261]:
Expected: "test.png"
Actual: "test.png (Cool image)"
</pre> Redmine - Defect #29038: Thumbnail macro causes attachment file not found and broken filename and link https://www.redmine.org/issues/29038?journal_id=859742018-07-02T02:36:45ZGo MAEDA
<ul><li><strong>Category</strong> changed from <i>Attachments</i> to <i>Text formatting</i></li><li><strong>Status</strong> changed from <i>New</i> to <i>Resolved</i></li><li><strong>Assignee</strong> set to <i>Go MAEDA</i></li></ul> Redmine - Defect #29038: Thumbnail macro causes attachment file not found and broken filename and link https://www.redmine.org/issues/29038?journal_id=859782018-07-02T03:09:46ZGo MAEDA
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li><li><strong>Resolution</strong> set to <i>Fixed</i></li></ul><p>Committed to the trunk and stable branches. Thank you for your contribution.</p> Redmine - Defect #29038: Thumbnail macro causes attachment file not found and broken filename and link https://www.redmine.org/issues/29038?journal_id=886482018-11-30T14:19:24ZMarius BÄ‚LTEANU
<ul><li><strong>Subject</strong> changed from <i>thumbnail macro causes attachment file not found and broken filename and link </i> to <i>Thumbnail macro causes attachment file not found and broken filename and link </i></li></ul>