Permalink
Browse files

All System (the class) functions can now take in spaced paths as long…

… as they are surrounded in quotes. Prior to this it was possible to do that by passing all values in as an array (related to #18362, #18440)

Fixed Bug #18362: A whitespace TEMP_DIR path breaks install/upgrade functionality [dufuz]
Fixed Bug #18440: bad tmp folder path on install : Unable to create path for C:/Program/tmp [dufuz]

git-svn-id: http://svn.php.net/repository/pear/pear-core/pear/pear-core/trunk@312909 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent 064b07d commit 808a2e233b068be0a168524beeb6ada4617593ae dufuz committed Jul 4, 2011
Showing with 26 additions and 8 deletions.
  1. +11 −2 PEAR/Builder.php
  2. +1 −1 PEAR/Command/Package.php
  3. +1 −1 PEAR/Downloader.php
  4. +1 −1 PEAR/Installer.php
  5. +1 −1 PEAR/PackageFile.php
  6. +11 −2 System.php
View
@@ -85,6 +85,7 @@ function _build_win32($descfile, $callback = null)
return $pkg;
}
}
+
$dir = dirname($descfile);
$old_cwd = getcwd();
@@ -108,6 +109,7 @@ function _build_win32($descfile, $callback = null)
if (!file_exists("$dir/$dsp")) {
return $this->raiseError("The DSP $dsp does not exist.");
}
+
// XXX TODO: make release build type configurable
$command = 'msdev '.$dsp.' /MAKE "'.$pkg->getPackage(). ' - Release"';
@@ -152,6 +154,7 @@ function _build_win32($descfile, $callback = null)
} else {
return $this->raiseError("Could not retrieve output information from $dsp.");
}
+
// realpath returns false if the file doesn't exist
if ($outfile && copy($outfile, "$dir/$out")) {
$outfile = "$dir/$out";
@@ -289,7 +292,7 @@ function build($descfile, $callback = null, $options = array())
// Find config. outside of normal path - e.g. config.m4
foreach (array_keys($pkg->getInstallationFileList()) as $item) {
- if (stristr(basename($item), 'config.m4')) {
+ if (stristr(basename($item), 'config.m4') && dirname($item) != '.') {
$dir .= DIRECTORY_SEPARATOR . dirname($item);
break;
}
@@ -368,7 +371,7 @@ function build($descfile, $callback = null, $options = array())
}
$tmpdir = $this->config->get('temp_dir');
- $build_basedir = System::mktemp(" -t $tmpdir -d pear-build-$user");
+ $build_basedir = System::mktemp(' -t "' . $tmpdir . '" -d "pear-build-' . $user . '"');
$build_dir = "$build_basedir/$vdir";
$inst_dir = "$build_basedir/install-$vdir";
$this->log(1, "building in $build_dir");
@@ -397,13 +400,15 @@ function build($descfile, $callback = null, $options = array())
if (!file_exists($build_dir) || !is_dir($build_dir) || !chdir($build_dir)) {
return $this->raiseError("could not chdir to $build_dir");
}
+
putenv('PHP_PEAR_VERSION=@PEAR-VER@');
foreach ($to_run as $cmd) {
$err = $this->_runCommand($cmd, $callback);
if (PEAR::isError($err)) {
chdir($old_cwd);
return $err;
}
+
if (!$err) {
chdir($old_cwd);
return $this->raiseError("`$cmd' failed");
@@ -483,6 +488,7 @@ function _runCommand($command, $callback = null)
if (!$pp) {
return $this->raiseError("failed to run `$command'");
}
+
if ($callback && $callback[0]->debug == 1) {
$olddbg = $callback[0]->debug;
$callback[0]->debug = 2;
@@ -495,6 +501,7 @@ function _runCommand($command, $callback = null)
$this->log(2, rtrim($line));
}
}
+
if ($callback && isset($olddbg)) {
$callback[0]->debug = $olddbg;
}
@@ -509,8 +516,10 @@ function log($level, $msg)
if ($this->debug >= $level) {
call_user_func($this->current_callback, 'output', $msg);
}
+
return;
}
+
return PEAR_Common::log($level, $msg);
}
}
View
@@ -974,7 +974,7 @@ function doSign($command, $options, $params)
$tar = new Archive_Tar($params[0]);
$tmpdir = $this->config->get('temp_dir');
- $tmpdir = System::mktemp(" -t $tmpdir -d pearsign");
+ $tmpdir = System::mktemp(' -t "' . $tmpdir . '" -d pearsign');
if (!$tar->extractList('package2.xml package.xml package.sig', $tmpdir)) {
return $this->raiseError("failed to extract tar file");
}
View
@@ -190,7 +190,7 @@ function discover($channel)
}
$tmpdir = $this->config->get('temp_dir');
- $tmp = System::mktemp("-d -t $tmpdir");
+ $tmp = System::mktemp('-d -t "' . $tmpdir . '"');
$a = $this->downloadHttp('http://' . $channel . '/channel.xml', $this->ui, $tmp, $callback, false);
PEAR::popErrorHandling();
if (PEAR::isError($a)) {
View
@@ -1104,7 +1104,7 @@ function install($pkgfile, $options = array())
if (realpath($descfile) != realpath($pkgfile)) {
// Use the temp_dir since $descfile can contain the download dir path
$tmpdir = $this->config->get('temp_dir', null, 'pear.php.net');
- $tmpdir = System::mktemp("-d -t $tmpdir");
+ $tmpdir = System::mktemp('-d -t "' . $tmpdir . '"');
$tar = new Archive_Tar($pkgfile);
if (!$tar->extract($tmpdir)) {
View
@@ -351,7 +351,7 @@ function &fromTgzFile($file, $state)
}
}
- $tmpdir = System::mktemp('-t ' . $this->_config->get('temp_dir') . ' -d pear');
+ $tmpdir = System::mktemp('-t "' . $this->_config->get('temp_dir') . '" -d pear');
if ($tmpdir === false) {
$ret = PEAR::raiseError("there was a problem with getting the configured temp directory");
return $ret;
View
@@ -71,9 +71,18 @@ class System
function _parseArgs($argv, $short_options, $long_options = null)
{
if (!is_array($argv) && $argv !== null) {
- $argv = preg_split('/\s+/', $argv, -1, PREG_SPLIT_NO_EMPTY);
+ // Find all items, quoted or otherwise
+ preg_match_all("/(?:[\"'])(.*?)(?:['\"])|([^\s]+)/", $argv, $av);
+ $argv = $av[1];
+ foreach ($av[2] as $k => $a) {
+ if (empty($a)) {
+ continue;
+ }
+ $argv[$k] = trim($a) ;
+ }
}
- return Console_Getopt::getopt2($argv, $short_options);
+
+ return Console_Getopt::getopt2($argv, $short_options, $long_options);
}
/**

0 comments on commit 808a2e2

Please sign in to comment.