anshuwap / mollify

Automatically exported from code.google.com/p/mollify
0 stars 0 forks source link

Plupload plugin 1.0.7 renames files unexpectedly #353

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Install mollify_1.8.6.1, Comment, FileViewerEditor, and Plupload 1.0.7
2. Upload 10 files with the names:
Capture_00001.JPG
Capture_00002.JPG
Capture_00003.JPG
Capture_00004.JPG
Capture_00005.JPG
Capture_00006.JPG
Capture_00007.JPG
Capture_00008.JPG
Capture_00009.JPG
Capture_00010.JPG

What is the expected output? What do you see instead?

Expect to see the ten files as listed.

Upload fails on Capture_00009.JPG.  The files that were uploaded have the 
following names:

Capture_00001.JPG
Capture_00003.JPG
Capture_00004.JPG
Capture_00005.JPG
Capture_00006.JPG
Capture_00007.JPG
Capture_00008.JPG
Capture_0000_3.JPG

(After several attempts there are also files in the /tmp directory like:
Capture_0000.JPG
Capture_0000_1.JPG
Capture_0000_2.JPG
Capture_0000_3.JPG
Capture_0001.JPG )

What version of the product are you using? On what operating system?

mollify_1.8.6.1, Plupload 1.0.7, PHP 5.3.9, Apache 2.2.21, Linux

Please provide any additional information below.

I tried clearing out the upload directory and the temp directory and 
reuploading.  Set "unique_names : true". Same error.

I uninstalled Plupload and tried uploading the same 10 files with the default 
uploader.  It worked fine.  The problem seems to be in the Pluploader plugin.

Original issue reported on code.google.com by aberk...@gmail.com on 18 Jan 2012 at 8:55

GoogleCodeExporter commented 9 years ago
Here are a couple of relevant lines from the Apache error log.  (IPs, URLs, and 
system paths have been lightly sanitized.)

[Wed Jan 18 02:03:48 2012] [error] [client 192.168.1.2] MOLLIFY ERROR: 
ServiceException: FILE_ALREADY_EXISTS=, referer: http://www.example.com/mollify/
[Wed Jan 18 02:03:48 2012] [error] [client 192.168.1.2] MOLLIFY ERROR: 
{0:{file:/var/www/htdocs/example.com/mollify/backend/include/filesystem/Filesyst
emItem.class.php, line:176, function:createFile, class:LocalFilesystem, 
type:->, args:{0:FILESYSTEMITEM Folder (LocalFilesystem): [4f166642ea041] = 
'AlbumCovers' (), 1:Capture_0000.JPG}}, 
1:{file:/var/www/htdocs/example.com/mollify/backend/include/filesystem/Filesyste
mController.class.php, line:567, function:createFile, class:Folder, type:->, 
args:{0:Capture_0000.JPG}}, 
2:{file:/var/www/htdocs/example.com/mollify/backend/plugin/Plupload/PluploadHand
ler.class.php, line:95, function:uploadFrom, class:FilesystemController, 
type:->, args:{0:FILESYSTEMITEM Folder (LocalFilesystem): [4f166642ea041] = 
'AlbumCovers' (), 1:Capture_0000.JPG, 2:Resource id #53}}, 
3:{file:/var/www/htdocs/example.com/mollify/backend/plugin/Plupload/PluploadServ
ices.class.php, line:40, function:uploadTo, class:PluploadHandler, type:->, 
args:{0:FILESYSTEMITEM Folder (LocalFilesystem): [4f166642ea041] = 
'AlbumCovers' (), 1:/tmp, 2:FILESYSTEMCONTROLLER}}, 
4:{file:/var/www/htdocs/example.com/mollify/backend/include/services/ServicesBas
e.class.php, line:60, function:processPost, class:PluploadServices, type:->, 
args:{}}, 
5:{file:/var/www/htdocs/example.com/mollify/backend/include/MollifyBackend.class
.php, line:78, function:processRequest, class:ServicesBase, type:->, args:{}}, 
6:{file:/var/www/htdocs/example.com/mollify/backend/r.php, line:57, 
function:processRequest, class:MollifyBackend, type:->, args:{0:Request}}}, 
referer: http://www.example.com/mollify/

Original comment by aberk...@gmail.com on 18 Jan 2012 at 9:02

GoogleCodeExporter commented 9 years ago
Could you try commenting out PluploadHandler.class.php line 42, it is the only 
line that processes the file name in any way.

Original comment by samuli.j...@gmail.com on 18 Jan 2012 at 7:06

GoogleCodeExporter commented 9 years ago
Yup.  That line was the problem.

I commented it out.  The uploads worked.

The intent of the code was to remove slashes and quotes.  The original line was:

$fileName = preg_replace("/[\47\92\34\39]+/", "", $fileName);

There are a few problems here.  The first is that all backslashes have to be 
doubled in regular expression strings.  The second is that characters either 
need to be expressed in octal or hex.  So the statement above was removing an 
odd mix that included the digits 2 and 9.

I rewrote the statement as:

$fileName = preg_replace("/[\\x2f\\x5c\\x22\\x27]+/", "", $fileName);

I tested the new statement by trying to upload files with slashes and quotes.  
It behaved as expected, properly striping out those characters but otherwise 
not mangling the filenames as it had before.

Thank you for pointing me in the right direction.

Original comment by aberk...@gmail.com on 19 Jan 2012 at 10:10

GoogleCodeExporter commented 9 years ago
You are right, thanks for correcting the regex pattern. I wonder how I didn't 
notice that :)

Original comment by samuli.j...@gmail.com on 19 Jan 2012 at 6:20

GoogleCodeExporter commented 9 years ago
Fixed in Plupload 1.0.8

Original comment by samuli.j...@gmail.com on 19 Jan 2012 at 6:23