Albums module assumes all filenames only have one '.' in

Bug #962400 reported by Ben Linsey-Bloom
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pluck CMS
Fix Committed
Low
Ben Linsey-Bloom

Bug Description

This is a fairly minor thing that I spotted in:
pluck-4_7/data/modules/albums/albums.admin.php - line 114.

list($image_filename, $ext) = explode('.', $_FILES['imagefile']['name']);

This assumes all filenames only have one dot ('.') in. If a filename has multiple dots in, anything between the second and third dot is considered to be the extension ($ext). Anything following the third dot is dropped from the filename.

eg. 'my.image.name.jpg' becomes 'my.image' when saved on the server.

I propose that we use the PHP function pathinfo(), and replace this:
list($image_filename, $ext) = explode('.', $_FILES['imagefile']['name']);

with this:
$image_filename = pathinfo($_FILES['imagefile']['name'], PATHINFO_FILENAME);
$ext = pathinfo($_FILES['imagefile']['name'], PATHINFO_EXTENSION) ;

Let me know what you think.

Related branches

Revision history for this message
Ben Linsey-Bloom (ben-kitserve) wrote :
Changed in pluck-cms:
assignee: nobody → Ben L-B (ben-kitserve)
Revision history for this message
Uranium235 (uranium235) wrote :

A little further down the code where the file is checked if it already exists, the code needs to be fixed as well. Your proposed solution unfortunately only wors since PHP 5.2, when the PATHINFO_FILENAME constant was introduced.
My solution would be to user strrpos() to find the last ".".

I fixed it in lp:~uranium235/pluck-cms/pluck-cms

Changed in pluck-cms:
status: New → Fix Committed
Changed in pluck-cms:
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.