From a50c04ea624f939e1c064ac2cfcf760fb5b6495d Mon Sep 17 00:00:00 2001 From: "Jessie N." <99688442+jessienab@users.noreply.github.com> Date: Fri, 4 Oct 2024 21:26:05 +0000 Subject: [PATCH] Update HasRandomIDAndLegacyTimeBasedID.php - Album ID Generation (#2554) * Update HasRandomIDAndLegacyTimeBasedID.php Modification of ID generation based on recommendation by associate who is a PHP developer. This will avoid having a hyphen at the end of URLs which seems to cause issues with certain apps/devices that do URL parsing. --------- Co-authored-by: ildyria --- app/Models/Extensions/HasRandomIDAndLegacyTimeBasedID.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Models/Extensions/HasRandomIDAndLegacyTimeBasedID.php b/app/Models/Extensions/HasRandomIDAndLegacyTimeBasedID.php index dc4e896ef11..b442465a323 100644 --- a/app/Models/Extensions/HasRandomIDAndLegacyTimeBasedID.php +++ b/app/Models/Extensions/HasRandomIDAndLegacyTimeBasedID.php @@ -152,6 +152,12 @@ private function generateKey(): void // As the number of bytes is divisible by 3, no trailing `=` occurs. try { $id = strtr(base64_encode(random_bytes(3 * RandomID::ID_LENGTH / 4)), '+/', '-_'); + // Last character whould not be a - for some version of android. + // this will reduce the entropy and induce a slight bias but we are still + // above the birthday bounds. + if ($id[23] === '-') { + $id[23] = '0'; + } } catch (\Exception $e) { throw new InsufficientEntropyException($e); }