From 7473e72419441ae32a5da763124c727ffb0d8fbe Mon Sep 17 00:00:00 2001 From: Andrei Shapiro Date: Thu, 22 Feb 2024 11:38:50 +0300 Subject: [PATCH] fix: set the maximum allowable value for URI - 36 characters --- core/kernel/uri/Bin2HexUriProvider.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/kernel/uri/Bin2HexUriProvider.php b/core/kernel/uri/Bin2HexUriProvider.php index c41bf13ef..40da620fa 100644 --- a/core/kernel/uri/Bin2HexUriProvider.php +++ b/core/kernel/uri/Bin2HexUriProvider.php @@ -49,7 +49,10 @@ class Bin2HexUriProvider extends ConfigurableService implements UriProvider */ public function provide() { - return $this->getOption(self::OPTION_NAMESPACE) . uniqid('i') . getmypid() - . bin2hex(openssl_random_pseudo_bytes(8)); + $uniqIdAndPid = uniqid('i') . getmypid(); + $bytesLength = floor((36 - strlen($uniqIdAndPid)) / 2); + + return $this->getOption(self::OPTION_NAMESPACE) . $uniqIdAndPid + . bin2hex(openssl_random_pseudo_bytes($bytesLength)); } }