From cf8ce82aa17a512007e5bf7da2ba937437fa6089 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 22 Dec 2022 15:28:49 +0100 Subject: [PATCH] Fix preg match type error in svn version guessing, fixes #11231 --- src/Composer/Package/Version/VersionGuesser.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Composer/Package/Version/VersionGuesser.php b/src/Composer/Package/Version/VersionGuesser.php index 06476e7dc..d7085c5d5 100644 --- a/src/Composer/Package/Version/VersionGuesser.php +++ b/src/Composer/Package/Version/VersionGuesser.php @@ -397,8 +397,8 @@ class VersionGuesser $urlPattern = '#.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))#'; - if (Preg::isMatchStrictGroups($urlPattern, $output, $matches)) { - if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) { + if (Preg::isMatch($urlPattern, $output, $matches)) { + if (isset($matches[2], $matches[3]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) { // we are in a branches path $version = $this->versionParser->normalizeBranch($matches[3]); $prettyVersion = 'dev-' . $matches[3]; @@ -406,6 +406,7 @@ class VersionGuesser return ['version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion]; } + assert(is_string($matches[1])); $prettyVersion = trim($matches[1]); if ($prettyVersion === 'trunk') { $version = 'dev-trunk';