From e9e2514b5e2734b7bb34b7933cf8ea082fb06643 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Feb 2016 00:01:42 +0000 Subject: [PATCH 1/3] Handle OpenSSL version after 26 patch releases e.g. https://github.com/openssl/openssl/blob/OpenSSL_0_9_8zh/crypto/opensslv.h#L33 --- src/Composer/Repository/PlatformRepository.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 833c82c20..1082c5404 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -146,8 +146,18 @@ class PlatformRepository extends ArrayRepository break; case 'openssl': - $prettyVersion = preg_replace_callback('{^(?:OpenSSL\s*)?([0-9.]+)([a-z]?).*}', function ($match) { - return $match[1] . (empty($match[2]) ? '' : '.'.(ord($match[2]) - 96)); + $prettyVersion = preg_replace_callback('{^(?:OpenSSL\s*)?([0-9.]+)([a-z]+).*}', function ($match) { + if (empty($match[2])) { + return $match[1]; + } + + // OpenSSL versions add another letter when they reach Z. + // e.g. OpenSSL 0.9.8zh 3 Dec 2015 + $patchVersion = array_sum(array_map(function ($letter) { + return ord($letter) - 96; + }, str_split($match[2]))); + + return $match[1].'.'.$patchVersion; }, OPENSSL_VERSION_TEXT); break; From f6f273c4b6df4cedc1a644578a82ff107067d1b8 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Feb 2016 00:10:34 +0000 Subject: [PATCH 2/3] Improve OpenSSL library description --- src/Composer/Repository/PlatformRepository.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 1082c5404..aa1335153 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -114,6 +114,7 @@ class PlatformRepository extends ArrayRepository // relying on them. foreach ($loadedExtensions as $name) { $prettyVersion = null; + $description = 'The '.$name.' PHP library'; switch ($name) { case 'curl': $curlVersion = curl_version(); @@ -159,6 +160,8 @@ class PlatformRepository extends ArrayRepository return $match[1].'.'.$patchVersion; }, OPENSSL_VERSION_TEXT); + + $description = OPENSSL_VERSION_TEXT; break; case 'pcre': @@ -185,7 +188,7 @@ class PlatformRepository extends ArrayRepository } $lib = new CompletePackage('lib-'.$name, $version, $prettyVersion); - $lib->setDescription('The '.$name.' PHP library'); + $lib->setDescription($description); $this->addPackage($lib); } From 0818a6ed5467f5cc76f67b71eb33f2c3eb366358 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Feb 2016 00:27:20 +0000 Subject: [PATCH 3/3] Previous attempt would cause 0.9.8aa == 0.9.8b --- src/Composer/Repository/PlatformRepository.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index aa1335153..27f52aa65 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -147,16 +147,22 @@ class PlatformRepository extends ArrayRepository break; case 'openssl': - $prettyVersion = preg_replace_callback('{^(?:OpenSSL\s*)?([0-9.]+)([a-z]+).*}', function ($match) { + $prettyVersion = preg_replace_callback('{^(?:OpenSSL\s*)?([0-9.]+)([a-z]*).*}', function ($match) { if (empty($match[2])) { return $match[1]; } // OpenSSL versions add another letter when they reach Z. // e.g. OpenSSL 0.9.8zh 3 Dec 2015 - $patchVersion = array_sum(array_map(function ($letter) { - return ord($letter) - 96; - }, str_split($match[2]))); + + if (!preg_match('{^z*[a-z]$}', $match[2])) { + // 0.9.8abc is garbage + return 0; + } + + $len = strlen($match[2]); + $patchVersion = ($len - 1) * 26; // All Z + $patchVersion += ord($match[2][$len - 1]) - 96; return $match[1].'.'.$patchVersion; }, OPENSSL_VERSION_TEXT);