From 15f7d24e7edfb74927b3d9416be5802d3ea31178 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 2 Jun 2022 21:15:18 +0200 Subject: [PATCH] Parse openssl 3 versions cleaner --- src/Composer/Platform/Version.php | 9 +++++++-- tests/Composer/Test/Platform/VersionTest.php | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Composer/Platform/Version.php b/src/Composer/Platform/Version.php index 6c9cd8fa5..a04d279f4 100644 --- a/src/Composer/Platform/Version.php +++ b/src/Composer/Platform/Version.php @@ -32,11 +32,16 @@ class Version return null; } + // OpenSSL 1 used 1.2.3a style versioning, 3+ uses semver + $patch = ''; + if (version_compare($matches['version'], '3.0.0', '<')) { + $patch = '.'.self::convertAlphaVersionToIntVersion($matches['patch']); + } + $isFips = strpos($matches['suffix'], 'fips') !== false; $suffix = strtr('-'.ltrim($matches['suffix'], '-'), array('-fips' => '', '-pre' => '-alpha')); - $patch = self::convertAlphaVersionToIntVersion($matches['patch']); - return rtrim($matches['version'].'.'.$patch.$suffix, '-'); + return rtrim($matches['version'].$patch.$suffix, '-'); } /** diff --git a/tests/Composer/Test/Platform/VersionTest.php b/tests/Composer/Test/Platform/VersionTest.php index 3ebb03724..edcca0041 100644 --- a/tests/Composer/Test/Platform/VersionTest.php +++ b/tests/Composer/Test/Platform/VersionTest.php @@ -69,6 +69,9 @@ class VersionTest extends TestCase array('1.2.3za', '1.2.3.27'), array('1.2.3zy', '1.2.3.51'), array('1.2.3zz', '1.2.3.52'), + // 3.x + array('3.0.0', '3.0.0', false, '3.0.0.0'), + array('3.2.4-dev', '3.2.4-dev', false, '3.2.4.0-dev'), ); }