php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58318 uploadprogress_get_info truncate filename
Submitted: 2008-08-18 20:37 UTC Modified: 2008-10-27 14:16 UTC
From: franck dot tab at gmail dot com Assigned:
Status: Closed Package: uploadprogress (PECL)
PHP Version: 5.2.0 OS: Debian 4
Private report: No CVE-ID: None
 [2008-08-18 20:37 UTC] franck dot tab at gmail dot com
Description:
------------
filename containing spaces are truncated.

Important note: only php function uploadprogress_get_info return bad information. Seem's the temporary file created while uploading contain the good informations.

In my test here is my tmp file:
upload_id=974489
fieldname=fichier_video
filename=C:\Documents and Settings\franck\Bureau\taf\tevasia\1and1\video\Kumar.flv
time_start=1219105999
time_last=1219106351
speed_average=49492
speed_last=51190
bytes_uploaded=17421484
bytes_total=28610177
files_uploaded=0
est_sec=226


Reproduce code:
---------------
Just upload a file from a Windows XP and, while uploading, take a look at what uploadprogress_get_info() return :

$infos=uploadprogress_get_info($id);

$filename=$infos['filename');

echo $filename;


Expected result:
----------------
C:\Documents and Settings\franck\Bureau\taf\tevasia\1and1\video\Kumar.flv

Actual result:
--------------
C:\Documents 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-19 09:42 UTC] franck dot tab at gmail dot com
The bug is when spaces are cleaned from the tmp file, line 393:

for (e=v; *e; e++) if (*e <= 32) { *e = 0; break; }

I'm not a C developper, but i'll try to find help and submit a patch. I have to take a look at chop() and trim() php function perhaps.
 [2008-08-21 08:34 UTC] franck dot tab at gmail dot com
Fixed with this the patch, any feedback will be appreciated:

381c381
<                 char *k, *v, *e;
---
>                 char *k, *v, *e, *z;
392,393c392
<                 for (e=k; *e; e++) if (*e <= 32) { *e = 0; break; }
<                 for (e=v; *e; e++) if (*e <= 32) { *e = 0; break; }
---
> 				for (e=k; *e; e++) if (*e <= 32) { *e = 0; break; }
394a394,403
> 				/* http://pecl.php.net/bugs/bug.php?id=14525 */
> 				// for (e=v; *e; e++) if (*e <= 32) { *e = 0; break; }
> 			
> 				if (v != NULL) {
> 					*z = v[strlen(v)];
> 					while (*z == ' ') {
> 						*z = 0;
> 						z--;
> 					}
> 				}
 [2008-08-21 08:49 UTC] franck dot tab at gmail dot com
The last patch add extra \n at the end. Not good, working on it.
 [2008-08-21 09:58 UTC] franck dot tab at gmail dot com
Here is the good one :

383a384
>                 int index = 0;
389c390
<                 /* trim spaces in front and after the name/value */
---
>                 /* trim spaces in front of the name/value */
391a393,394
> 
>                 /* trim spaces everywhere in the name */
393d395
<                 for (e=v; *e; e++) if (*e <= 32) { *e = 0; break; }
394a397,407
>                 /* trim spaces only at the end of the value */
> 
>                 /* http://pecl.php.net/bugs/bug.php?id=14525 */
>                 //for (e=v; *e; e++) if (*e <= 32) { *e = 0; break; }
> 
>                 if (v != NULL) {
>                     for (index = strlen(v); index > 0; index--) {
>                         if (v[index] > 32) break;
>                         v[index] = 0;
>                     }	
>                 }


Thanks to matthieu estrade and myself :)
 [2008-10-27 14:16 UTC] chregu@php.net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

Just committed your patch, please test
 [2011-08-17 21:50 UTC] max at mustermann dot de
What a great rseoucre this text is.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Nov 19 21:01:35 2019 UTC