Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Do not save invalid display name to the database
Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal authored and backportbot-nextcloud[bot] committed Jul 6, 2022
commit 51e20dd6c56e8f9221f9019f83a2abe61a90c4f6
4 changes: 3 additions & 1 deletion apps/provisioning_api/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,9 @@ public function editUser(string $userId, string $key, string $value): DataRespon
switch ($key) {
case self::USER_FIELD_DISPLAYNAME:
case IAccountManager::PROPERTY_DISPLAYNAME:
$targetUser->setDisplayName($value);
if (!$targetUser->setDisplayName($value)) {
throw new OCSException('Invalid displayname', 102);
}
break;
case self::USER_FIELD_QUOTA:
$quota = $value;
Expand Down
4 changes: 4 additions & 0 deletions lib/private/User/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ public function setPassword(string $uid, string $password): bool {
* Change the display name of a user
*/
public function setDisplayName(string $uid, string $displayName): bool {
if (mb_strlen($displayName) > 64) {
return false;
}

$this->fixDI();

if ($this->userExists($uid)) {
Expand Down