summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib/User
diff options
context:
space:
mode:
authorVictor Dubiniuk <victor.dubiniuk@gmail.com>2016-09-23 01:30:57 +0300
committerArthur Schiwon <blizzz@arthur-schiwon.de>2016-10-13 00:53:34 +0200
commit011d5f554c1fcc2896c8798c9ef29b59af7b2692 (patch)
treea82d4724e97221a2cf05fb3e5c2c39fc8a462321 /apps/user_ldap/lib/User
parent17fa45a29200ced15b4258f2d06d8159b60856f9 (diff)
downloadnextcloud-server-011d5f554c1fcc2896c8798c9ef29b59af7b2692.tar.gz
nextcloud-server-011d5f554c1fcc2896c8798c9ef29b59af7b2692.zip
Harden empty
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/lib/User')
-rw-r--r--apps/user_ldap/lib/User/User.php27
1 files changed, 14 insertions, 13 deletions
diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php
index b2fcac10641..e29b10616ca 100644
--- a/apps/user_ldap/lib/User/User.php
+++ b/apps/user_ldap/lib/User/User.php
@@ -183,13 +183,13 @@ class User {
$displayName = $displayName2 = '';
$attr = strtolower($this->connection->ldapUserDisplayName);
if(isset($ldapEntry[$attr])) {
- $displayName = $ldapEntry[$attr][0];
+ $displayName = strval($ldapEntry[$attr][0]);
}
$attr = strtolower($this->connection->ldapUserDisplayName2);
if(isset($ldapEntry[$attr])) {
- $displayName2 = $ldapEntry[$attr][0];
+ $displayName2 = strval($ldapEntry[$attr][0]);
}
- if(!empty($displayName)) {
+ if ($displayName !== '') {
$this->composeAndStoreDisplayName($displayName);
$this->access->cacheUserDisplayName(
$this->getUsername(),
@@ -261,10 +261,10 @@ class User {
* @throws \Exception
*/
public function getHomePath($valueFromLDAP = null) {
- $path = $valueFromLDAP;
+ $path = strval($valueFromLDAP);
$attr = null;
- if( is_null($path)
+ if (is_null($valueFromLDAP)
&& strpos($this->access->connection->homeFolderNamingRule, 'attr:') === 0
&& $this->access->connection->homeFolderNamingRule !== 'attr:')
{
@@ -276,7 +276,7 @@ class User {
}
}
- if(!empty($path)) {
+ if ($path !== '') {
//if attribute's value is an absolute path take this, otherwise append it to data dir
//check for / at the beginning or pattern c:\ resp. c:/
if( '/' !== $path[0]
@@ -393,7 +393,8 @@ class User {
* @returns string the effective display name
*/
public function composeAndStoreDisplayName($displayName, $displayName2 = '') {
- if(!empty($displayName2)) {
+ $displayName2 = strval($displayName2);
+ if($displayName2 !== '') {
$displayName .= ' (' . $displayName2 . ')';
}
$this->store('displayName', $displayName);
@@ -432,20 +433,20 @@ class User {
if($this->wasRefreshed('email')) {
return;
}
- $email = $valueFromLDAP;
+ $email = strval($valueFromLDAP);
if(is_null($valueFromLDAP)) {
$emailAttribute = $this->connection->ldapEmailAttribute;
- if(!empty($emailAttribute)) {
+ if ($emailAttribute !== '') {
$aEmail = $this->access->readAttribute($this->dn, $emailAttribute);
if(is_array($aEmail) && (count($aEmail) > 0)) {
- $email = $aEmail[0];
+ $email = strval($aEmail[0]);
}
}
}
- if(!is_null($email)) {
+ if ($email !== '') {
$user = $this->userManager->get($this->uid);
if (!is_null($user)) {
- $currentEmail = $user->getEMailAddress();
+ $currentEmail = strval($user->getEMailAddress());
if ($currentEmail !== $email) {
$user->setEMailAddress($email);
}
@@ -470,7 +471,7 @@ class User {
if(is_null($valueFromLDAP)) {
$quotaAttribute = $this->connection->ldapQuotaAttribute;
- if(!empty($quotaAttribute)) {
+ if ($quotaAttribute !== '') {
$aQuota = $this->access->readAttribute($this->dn, $quotaAttribute);
if($aQuota && (count($aQuota) > 0)) {
$quota = $aQuota[0];