diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php index 18785c4e7..ccc49396a 100644 --- a/src/Composer/Repository/VcsRepository.php +++ b/src/Composer/Repository/VcsRepository.php @@ -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('Skipped cached version '.$version.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$cachedPackage['version_normalized'].' internally'); }