Bugs: Browse | Submit New | Admin

[#27891] temp files are sometimes generated with two dots before the extension

Date:
2010-02-25 17:14
Priority:
3
Submitted By:
Mike Johnson (architeuthis)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
temp files are sometimes generated with two dots before the extension

Detailed description
Under Windows XP using Ruby 1.8.7 and MiniMagick 1.2.5, temp files generated by MiniMagick::Image.from_file had file
names like "mini_magick1944-0..jpg".

The two dots before the extension shouldn't cause any problems, but certain applications that manipulate image file
names might contain regular expressions that are not prepared to deal with the double dots, resulting in errors.
Specifically, this caused errors for me with attachment_fu.

Ruby File.extname returns a dot in its results, but the MiniMagick code assumes no dot. I'm guessing at some point in
the past or on other operating systems, File.extname does not return a dot. The solution is simply to check for the
dot when generating a tempfile name:

Suggested fix, line 6 of lib/image_temp_file.rb change from:

'mini_magick%d-%d%s' % [$$, n, ext ? ".#{ext}" : '']

to:

'mini_magick%d-%d%s' % [$$, n, ext ? "#{('.' unless ext =~ /^\./)}#{ext}" : '']

Add A Comment: Notepad

Please login


Followup

Message
Date: 2010-02-25 17:20
Sender: Mike Johnson

My attachment_fu problem was caused by something else, but
this is still a bug. Low priority.

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item