aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/user/user.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/user/user.php')
-rw-r--r--lib/private/user/user.php14
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;