Skip to content

Commit

Permalink
Merge pull request #28495 from nextcloud/backport/28481/stable21
Browse files Browse the repository at this point in the history
[stable21] Hash cache key
  • Loading branch information
Pytal authored Aug 18, 2021
2 parents df87216 + 7aa75c7 commit 8452f8c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/private/User/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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);
}
}
Expand Down

0 comments on commit 8452f8c

Please sign in to comment.