diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2014-10-15 14:05:18 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2014-10-15 14:54:35 +0200 |
commit | 239bff5766c42e94e430dfdc4233ac4115c516ec (patch) | |
tree | 5597376577eb02b177b58339e6b617fcef1aaddb /lib/private/user | |
parent | 6fa03870e9d0de5c0ff9fff120c4b06e6f94c4a0 (diff) | |
download | nextcloud-server-239bff5766c42e94e430dfdc4233ac4115c516ec.tar.gz nextcloud-server-239bff5766c42e94e430dfdc4233ac4115c516ec.zip |
strip whitespace from the beginning and end of the display name to avoid empty display names
Diffstat (limited to 'lib/private/user')
-rw-r--r-- | lib/private/user/user.php | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/private/user/user.php b/lib/private/user/user.php index 993fb4c0c64..452261a75ff 100644 --- a/lib/private/user/user.php +++ b/lib/private/user/user.php @@ -89,8 +89,17 @@ class User implements IUser { */ public function getDisplayName() { if (!isset($this->displayName)) { + $displayName = ''; if ($this->backend and $this->backend->implementsActions(OC_USER_BACKEND_GET_DISPLAYNAME)) { - $this->displayName = $this->backend->getDisplayName($this->uid); + // get display name and strip whitespace from the beginning and end of it + $backendDisplayName = $this->backend->getDisplayName($this->uid); + if (is_string($backendDisplayName)) { + $displayName = trim($backendDisplayName); + } + } + + if (!empty($displayName)) { + $this->displayName = $displayName; } else { $this->displayName = $this->uid; } @@ -105,7 +114,8 @@ class User implements IUser { * @return bool */ public function setDisplayName($displayName) { - if ($this->canChangeDisplayName()) { + $displayName = trim($displayName); + if ($this->canChangeDisplayName() && !empty($displayName)) { $this->displayName = $displayName; $result = $this->backend->setDisplayName($this->uid, $displayName); return $result !== false; |