Skip to content

Commit

Permalink
Merge pull request #28494 from nextcloud/backport/28481/stable22
Browse files Browse the repository at this point in the history
[stable22] Hash cache key
  • Loading branch information
Pytal authored Aug 18, 2021
2 parents e1d9a45 + 79b5421 commit f3f1c82
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 @@ -158,7 +158,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 @@ -174,7 +174,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 f3f1c82

Please sign in to comment.