Fix issues handling branch names with pipes in them

main
Jordi Boggiano 4 years ago
parent 05737a46fb
commit 7a270955f5
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -20,6 +20,7 @@ use Composer\Package\Loader\ValidatingArrayLoader;
use Composer\Package\Loader\InvalidPackageException;
use Composer\Package\Loader\LoaderInterface;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Semver\Constraint\Constraint;
use Composer\IO\IOInterface;
use Composer\Config;
@ -363,7 +364,12 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
private function validateBranch($branch)
{
try {
return $this->versionParser->normalizeBranch($branch);
$normalizedBranch = $this->versionParser->normalizeBranch($branch);
// validate that the branch name has no weird characters conflicting with constraints
$this->versionParser->parseConstraints($normalizedBranch);
return $normalizedBranch;
} catch (\Exception $e) {
}
@ -403,7 +409,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
$this->io->overwriteError($msg, false);
}
if ($existingPackage = $this->findPackage($cachedPackage['name'], $cachedPackage['version_normalized'])) {
if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) {
if ($isVeryVerbose) {
$this->io->writeError('<warning>Skipped cached version '.$version.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$cachedPackage['version_normalized'].' internally</warning>');
}

Loading…
Cancel
Save