|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23930 PEAR_Packager::package can't handle filenames with spaces in the path
Submitted: 2003-05-31 17:50 UTC Modified: 2003-06-24 16:22 UTC
From: greg at chiaraquartet dot net Assigned: vblavet (profile)
Status: Closed Package: PEAR related
PHP Version: 4.3.2 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: greg at chiaraquartet dot net
New email:
PHP Version: OS:


 [2003-05-31 17:50 UTC] greg at chiaraquartet dot net
the createModify parameter specification allows files separated by spaces, or a single filename.  This does not take into account the possibility of directories with spaces in them.

The best solution is to change the space to an impossible OS character, such as : or ; (this is why include_path uses : instead of spaces).

This affects all aspects of the pear packaging process as well, so changes here will require changes elsewhere that Archive_Tar is used.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-31 18:34 UTC]
et@edea:/tmp/foo$ touch foo\:bar
et@edea:/tmp/foo$ touch foo\;bar
et@edea:/tmp/foo$ ls
foo:bar  foo;bar

; and : are perfectly allowable characters, just like a space. the solution would rather be to a) quote the filenames and b) allow escaping of characters, but that is not a simple thing to do. 
 [2003-05-31 20:24 UTC] greg at chiaraquartet dot net
perhaps the best solution is to allow either a string (single filename) or an array of strings (multiple filenames)
 [2003-06-01 01:28 UTC]
Actually, that is almost what it is doing. It accepts a string (space-delimited) or an array of path/filenames. So, if you have something that contains spaces, all you have to do is put them into an array. $foo->createModify(array('path/with spaces/to/file')); I suggest leaving it as-is, because it would break BC otherwise. Quoting/escaping would be nice, but is not really neccessary, i think. One easy thing that one could do though is introducing a 5th parameter (optional) specifying the delimiter for the filelist, defaulting to a space. Assigning this to the maintainer, he should decide what do to.
 [2003-06-02 15:37 UTC]
Greg, 'et',
Both of you are right !
The use of blank space for file separation was really not a good idea, but it is now historical, and for compatibility reason we should keep it like that.
Archive_Tar is working "as designed" and documented, and like stated by 'et' the best solution is to use an array to pass the file name.
I will explore the available solutions. I would prefer a new method like set(attribute_name, value) to fix the separator for those you want to. We can also detect windows OS and do some specific tricks ... to invent.
I will also try to find where in the PEAR package engine we are using these methods to improve the call by using arrays.
Any suggestion is welcomed.
 [2003-06-02 16:06 UTC] greg at chiaraquartet dot net

It's always nice when everyone can be correct :)

I did a full-text search for createModify, and it is used in PEAR_Packager::package() on line 138 of Packager.php.  All one needs to do is add an array() around $newpkgfile in:

        $ok = $tar->createModify($newpkgfile, '', $tmpdir);

to get:

        $ok = $tar->createModify(array($newpkgfile), '', $tmpdir);

In addition (and this is minor), I would suggest changing the PHPDoc @param for createModify() (which is by the way extremely useful and well-written, a pleasure to read).  instead of @param string  <description> try @param string|array <description>, this will allow people glancing at it to figure out what the exact types allowed are.

Otherwise, I'm changing this bug's summary to match what is really going on.
 [2003-06-24 16:22 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

Added a new attribute in Archive_Tar to change the separator while adding several files in a single char string. This attribute must be set with the new method setAttribute(). The default separator remains ' ' for backward Compatibility.
Sample :
$archive->setAttribute(ARCHIVE_TAR_ATT_SEPARATOR, ',');
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 17 08:03:36 2021 UTC