aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-10-15 14:05:18 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-10-15 14:54:35 +0200
commit239bff5766c42e94e430dfdc4233ac4115c516ec (patch)
tree5597376577eb02b177b58339e6b617fcef1aaddb /lib
parent6fa03870e9d0de5c0ff9fff120c4b06e6f94c4a0 (diff)
downloadnextcloud-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')
-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;