From 7aa75c7b5ef4146e75539bcc432b074b9c9661af Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Tue, 17 Aug 2021 17:57:21 +0000 Subject: [PATCH] Hash cache key Signed-off-by: Christopher Ng --- lib/private/User/Manager.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index 59c007b6b59a3..fca642473d9b1 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -159,7 +159,7 @@ public function get($uid) { return $this->cachedUsers[$uid]; } - $cachedBackend = $this->cache->get($uid); + $cachedBackend = $this->cache->get(sha1($uid)); if ($cachedBackend !== null && isset($this->backends[$cachedBackend])) { // Cache has the info of the user backend already, so ask that one directly $backend = $this->backends[$cachedBackend]; @@ -175,7 +175,8 @@ public function get($uid) { } if ($backend->userExists($uid)) { - $this->cache->set($uid, $i, 300); + // Hash $uid to ensure that only valid characters are used for the cache key + $this->cache->set(sha1($uid), $i, 300); return $this->getUserObject($uid, $backend); } }