#24845 [NEW]: spaces in pathname make PEAR fail

From: Date: Mon, 28 Jul 2003 22:57:08 +0000
Subject: #24845 [NEW]: spaces in pathname make PEAR fail
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-18853@lists.php.net to get a copy of this message
From: greg at chiaraquartet dot net Operating system: Windows PHP version: 4.3.2 PHP Bug Type: PEAR related Bug description: spaces in pathname make PEAR fail Description: ------------ As we all know, PEAR fails when there are spaces in the pathname. This is an old bug. However, I have good news: I have a patch that fixes this for all commands. Here is a patch. Note that this patch also applies new publicweb functionality to Config.php. I'll generate a patch for all the changes I've made today. I do have commit access, so if this patch looks good, I'll just commit the code. Greg P.S. this is quite exciting for me - PEAR has never worked properly with spaces, and now it will with no API change or BC problems Index: pear/PEAR/Common.php =================================================================== RCS file: /repository/php-src/pear/PEAR/Common.php,v retrieving revision 1.93 diff -u -r1.93 Common.php --- pear/PEAR/Common.php 12 Jul 2003 15:15:38 -0000 1.93 +++ pear/PEAR/Common.php 28 Jul 2003 22:50:10 -0000 @@ -63,7 +63,7 @@ * Valid file roles * @var array */ -$GLOBALS['_PEAR_Common_file_roles'] = array('php','ext','test','doc','data','src','script'); +$GLOBALS['_PEAR_Common_file_roles'] = array('php','ext','test','doc','data','src','script','publicweb'); /** * Valid replacement types @@ -156,7 +156,12 @@ $tempfiles =& $GLOBALS['_PEAR_Common_tempfiles']; while ($file = array_shift($tempfiles)) { if (@is_dir($file)) { - System::rm("-rf $file"); + $options = + array( + '-rf', + $file, + ); + System::rm($options); } elseif (file_exists($file)) { unlink($file); } @@ -198,7 +203,12 @@ function mkDirHier($dir) { $this->log(2, "+ create dir $dir"); - return System::mkDir("-p $dir"); + $options = + array( + '-p', + $dir, + ); + return System::mkDir($options); } // }}} @@ -242,11 +252,12 @@ function mkTempDir($tmpdir = '') { if ($tmpdir) { - $topt = "-t $tmpdir "; + $topt = array('-t', $tmpdir); } else { - $topt = ''; + $topt = array(); } - if (!$tmpdir = System::mktemp($topt . '-d pear')) { + $topt = array_merge($topt, array('-d', 'pear')); + if (!$tmpdir = System::mktemp($topt)) { return false; } $this->addTempFile($tmpdir); Index: pear/PEAR/Config.php =================================================================== RCS file: /repository/php-src/pear/PEAR/Config.php,v retrieving revision 1.48 diff -u -r1.48 Config.php --- pear/PEAR/Config.php 3 Jul 2003 06:43:31 -0000 1.48 +++ pear/PEAR/Config.php 28 Jul 2003 22:50:11 -0000 @@ -112,6 +112,15 @@ $PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'data'); } +// Default for publicweb dir +if (getenv('PHP_PEAR_PUBLICWEB_DIR')) { + define('PEAR_CONFIG_DEFAULT_PUBLICWEB_DIR', getenv('PHP_PEAR_PUBLICWEB_DIR')); +} else { + // use the data directory if no publicweb option is defined + define('PEAR_CONFIG_DEFAULT_PUBLICWEB_DIR', + PEAR_CONFIG_DEFAULT_DATA_DIR); +} + // Default for test_dir if (getenv('PHP_PEAR_TEST_DIR')) { define('PEAR_CONFIG_DEFAULT_TEST_DIR', getenv('PHP_PEAR_TEST_DIR')); @@ -279,6 +288,13 @@ 'prompt' => 'PEAR executables directory', 'group' => 'File Locations', ), + 'publicweb_dir' => array( + 'type' => 'directory', + 'default' => PEAR_CONFIG_DEFAULT_PUBLICWEB_DIR, + 'doc' => 'sub-directory of http doc root where public html-related files are installed', + 'prompt' => 'PEAR html-files directory', + 'group' => 'File Locations', + ), 'data_dir' => array( 'type' => 'directory', 'default' => PEAR_CONFIG_DEFAULT_DATA_DIR, @@ -577,7 +593,8 @@ } $data = ($data === null) ? $this->configuration[$layer] : $data; $this->_encodeOutput($data); - if (!@System::mkDir("-p " . dirname($file))) { + $opt = array('-p', dirname($file)); + if (!@System::mkDir($opt)) { return $this->raiseError("could not create directory: " . dirname($file)); } if (@is_file($file) && !@is_writeable($file)) { Index: pear/PEAR/Installer.php =================================================================== RCS file: /repository/php-src/pear/PEAR/Installer.php,v retrieving revision 1.92 diff -u -r1.92 Installer.php --- pear/PEAR/Installer.php 8 Jul 2003 10:33:38 -0000 1.92 +++ pear/PEAR/Installer.php 28 Jul 2003 22:50:11 -0000 @@ -180,6 +180,7 @@ break; case 'ext': case 'php': + case 'publicweb': $dest_dir = $this->config->get($atts['role'] . '_dir'); break; case 'script': Index: pear/PEAR/Packager.php =================================================================== RCS file: /repository/php-src/pear/PEAR/Packager.php,v retrieving revision 1.48 diff -u -r1.48 Packager.php --- pear/PEAR/Packager.php 27 Jun 2003 10:46:53 -0000 1.48 +++ pear/PEAR/Packager.php 28 Jul 2003 22:50:12 -0000 @@ -116,7 +116,13 @@ chdir($oldcwd); return $this->raiseError($new_xml); } - if (!($tmpdir = System::mktemp('-t '.getcwd().' -d'))) { + $opt = + array( + '-t', + getcwd(), + '-d', + ); + if (!($tmpdir = System::mktemp($opt))) { chdir($oldcwd); return $this->raiseError("PEAR_Packager: mktemp failed"); } @@ -135,7 +141,7 @@ $tar =& new Archive_Tar($dest_package, $compress); $tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors // ----- Creates with the package.xml file - $ok = $tar->createModify($newpkgfile, '', $tmpdir); + $ok = $tar->createModify(array($newpkgfile), '', $tmpdir); if (PEAR::isError($ok)) { chdir($oldcwd); return $this->raiseError($ok); Index: pear/PEAR/Registry.php =================================================================== RCS file: /repository/php-src/pear/PEAR/Registry.php,v retrieving revision 1.46 diff -u -r1.46 Registry.php --- pear/PEAR/Registry.php 7 Jul 2003 15:42:58 -0000 1.46 +++ pear/PEAR/Registry.php 28 Jul 2003 22:50:12 -0000 @@ -146,7 +146,11 @@ function _assertStateDir() { if (!@is_dir($this->statedir)) { - if (!System::mkdir("-p {$this->statedir}")) { + $opt = array( + '-p', + $this->statedir, + ); + if (!System::mkdir($opt)) { return $this->raiseError("could not create directory '{$this->statedir}'"); } } Index: pear/PEAR/Remote.php =================================================================== RCS file: /repository/php-src/pear/PEAR/Remote.php,v retrieving revision 1.41 diff -u -r1.41 Remote.php --- pear/PEAR/Remote.php 12 Jul 2003 14:25:06 -0000 1.41 +++ pear/PEAR/Remote.php 28 Jul 2003 22:50:12 -0000 @@ -56,7 +56,8 @@ $id = md5(serialize($args)); $cachedir = $this->config->get('cache_dir'); if (!file_exists($cachedir)) { - System::mkdir('-p '.$cachedir); + $opt = array('-p', $cachedir); + System::mkdir($opt); } $filename = $cachedir . DIRECTORY_SEPARATOR . 'xmlrpc_cache_' . $id; if (!file_exists($filename)) { @@ -86,7 +87,8 @@ $id = md5(serialize($args)); $cachedir = $this->config->get('cache_dir'); if (!file_exists($cachedir)) { - System::mkdir('-p '.$cachedir); + $opt = array('-p', $cachedir); + System::mkdir($opt); } $filename = $cachedir.'/xmlrpc_cache_'.$id; Reproduce code: --------------- try any pear command/installation that involves writing to disk and creating temp files in C:\Program Files\PHP -- Edit bug report at http://bugs.php.net/?id=24845&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24845&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24845&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=24845&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24845&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24845&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24845&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24845&r=support Expected behavior: http://bugs.php.net/fix.php?id=24845&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24845&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24845&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24845&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24845&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24845&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24845&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24845&r=gnused

« previous php.pear.dev (#18853) next »