From 9abfd25765be177ddacf74a93123ecc9e9b2b9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Tue, 30 Jul 2024 22:47:22 +0200 Subject: [PATCH] [Uid] Ensure UuidV1 is created in lowercase --- src/Symfony/Component/Uid/Tests/UuidTest.php | 9 +++++++++ src/Symfony/Component/Uid/UuidV1.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Uid/Tests/UuidTest.php b/src/Symfony/Component/Uid/Tests/UuidTest.php index 1affd73af47f2..00a970dd65cc5 100644 --- a/src/Symfony/Component/Uid/Tests/UuidTest.php +++ b/src/Symfony/Component/Uid/Tests/UuidTest.php @@ -90,6 +90,15 @@ public function testV1() $this->assertSame('3499710062d0', $uuid->getNode()); } + public function testV1IsLowerCase() + { + $uuid = new UuidV1(); + $this->assertSame(strtolower((string) $uuid), (string) $uuid); + + $uuid = new UuidV1('D9E7A184-5D5B-11EA-A62A-3499710062D0'); + $this->assertSame(strtolower((string) $uuid), (string) $uuid); + } + public function testV3() { $uuid = Uuid::v3(new UuidV4(self::A_UUID_V4), 'the name'); diff --git a/src/Symfony/Component/Uid/UuidV1.php b/src/Symfony/Component/Uid/UuidV1.php index 9e92ff0661ba3..6132fd1f239ce 100644 --- a/src/Symfony/Component/Uid/UuidV1.php +++ b/src/Symfony/Component/Uid/UuidV1.php @@ -25,7 +25,7 @@ class UuidV1 extends Uuid public function __construct(?string $uuid = null) { if (null === $uuid) { - $this->uid = uuid_create(static::TYPE); + $this->uid = strtolower(uuid_create(static::TYPE)); } else { parent::__construct($uuid, true); }