Trim trailing slash in path downloader to avoid symlink issues, and in FileDownloader::getLocalChanges as we append a string without slash, refs #9422
parent
c04c42b7b4
commit
bc9336946e
|
@ -429,6 +429,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
$e = null;
|
$e = null;
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
|
$targetDir = Filesystem::trimTrailingSlash($targetDir);
|
||||||
try {
|
try {
|
||||||
if (is_dir($targetDir.'_compare')) {
|
if (is_dir($targetDir.'_compare')) {
|
||||||
$this->filesystem->removeDirectory($targetDir.'_compare');
|
$this->filesystem->removeDirectory($targetDir.'_compare');
|
||||||
|
|
|
@ -47,6 +47,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
||||||
*/
|
*/
|
||||||
public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
|
public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
|
||||||
{
|
{
|
||||||
|
$path = Filesystem::trimTrailingSlash($path);
|
||||||
$url = $package->getDistUrl();
|
$url = $package->getDistUrl();
|
||||||
$realUrl = realpath($url);
|
$realUrl = realpath($url);
|
||||||
if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
|
if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
|
||||||
|
@ -80,6 +81,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
||||||
*/
|
*/
|
||||||
public function install(PackageInterface $package, $path, $output = true)
|
public function install(PackageInterface $package, $path, $output = true)
|
||||||
{
|
{
|
||||||
|
$path = Filesystem::trimTrailingSlash($path);
|
||||||
$url = $package->getDistUrl();
|
$url = $package->getDistUrl();
|
||||||
$realUrl = realpath($url);
|
$realUrl = realpath($url);
|
||||||
|
|
||||||
|
@ -178,6 +180,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
||||||
*/
|
*/
|
||||||
public function remove(PackageInterface $package, $path, $output = true)
|
public function remove(PackageInterface $package, $path, $output = true)
|
||||||
{
|
{
|
||||||
|
$path = Filesystem::trimTrailingSlash($path);
|
||||||
/**
|
/**
|
||||||
* realpath() may resolve Windows junctions to the source path, so we'll check for a junction first
|
* realpath() may resolve Windows junctions to the source path, so we'll check for a junction first
|
||||||
* to prevent a false positive when checking if the dist and install paths are the same.
|
* to prevent a false positive when checking if the dist and install paths are the same.
|
||||||
|
@ -209,6 +212,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
||||||
*/
|
*/
|
||||||
public function getVcsReference(PackageInterface $package, $path)
|
public function getVcsReference(PackageInterface $package, $path)
|
||||||
{
|
{
|
||||||
|
$path = Filesystem::trimTrailingSlash($path);
|
||||||
$parser = new VersionParser;
|
$parser = new VersionParser;
|
||||||
$guesser = new VersionGuesser($this->config, $this->process, $parser);
|
$guesser = new VersionGuesser($this->config, $this->process, $parser);
|
||||||
$dumper = new ArrayDumper;
|
$dumper = new ArrayDumper;
|
||||||
|
|
|
@ -506,6 +506,23 @@ class Filesystem
|
||||||
return $prefix.($absolute ? '/' : '').implode('/', $parts);
|
return $prefix.($absolute ? '/' : '').implode('/', $parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove trailing slashes if present to avoid issues with symlinks
|
||||||
|
*
|
||||||
|
* And other possible unforeseen disasters, see https://github.com/composer/composer/pull/9422
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function trimTrailingSlash($path)
|
||||||
|
{
|
||||||
|
if (!preg_match('{^[/\\\\]+$}', $path)) {
|
||||||
|
$path = rtrim($path, '/\\');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return if the given path is local
|
* Return if the given path is local
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue