diff options
author | Aleksander Machniak <alec@alec.pl> | 2014-01-07 12:08:20 +0100 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2014-01-07 12:09:28 +0100 |
commit | b0adb904918c43251bbf6c969bf3e24ea4733fd8 (patch) | |
tree | 50459c9a25bf8694fbc7b58886a25c249de04830 | |
parent | 64e84bb211baad7d6b5d65f34c00ad2d296a246c (diff) | |
download | webadmin-kolab-webadmin-3.1.4.tar.gz |
Revert commit 109ad37d making email addresses case-insensitivekolab-webadmin-3.1.4
-rw-r--r-- | lib/Auth/LDAP.php | 20 | ||||
-rw-r--r-- | lib/api/kolab_api_service_form_value.php | 11 | ||||
-rw-r--r-- | lib/functions.php | 18 |
3 files changed, 7 insertions, 42 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php index 8ef191e..5850672 100644 --- a/lib/Auth/LDAP.php +++ b/lib/Auth/LDAP.php @@ -594,25 +594,7 @@ class LDAP extends Net_LDAP3 { $result = $this->search_entries($this->config_get('root_dn'), '(objectclass=*)', 'sub', null, $search); if ($result && $result->count() > 0) { - $result = $result->entries(true); - - // LDAP searches are case-insensitive, post-process result - // with correct character case handling - foreach ($result as $key => $user) { - foreach ($user as $attr => $list) { - foreach ((array) $list as $addr) { - if (compare_email($address, $addr)) { - continue 3; - } - } - } - - unset($result[$key]); - } - - reset($result); - - return $result; + return $result->entries(true); } return false; diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php index a8cea72..2cb1799 100644 --- a/lib/api/kolab_api_service_form_value.php +++ b/lib/api/kolab_api_service_form_value.php @@ -1087,14 +1087,15 @@ class kolab_api_service_form_value extends kolab_api_service // from e.g. adding primary mail address into aliases list $found = false; $user = $users[$user_found_dn]; + $addr = mb_strtolower($addr); + unset($user[$attr_name]); foreach ($user as $attr => $list) { - foreach ((array) $list as $email) { - if (compare_email($addr, $email)) { - $found = true; - break 2; - } + $list = array_map('mb_strtolower', (array) $list); + if (in_array($addr, $list)) { + $found = true; + break; } } diff --git a/lib/functions.php b/lib/functions.php index ce73a13..98dc949 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -131,21 +131,3 @@ function timer($time = null, $label = '') } return $now; } - -/** - * Compare two email addresses with correct character-case handling - * i.e. local part is case-sensitive, domain part is not - */ -function compare_email($email1, $email2) -{ - $email1 = explode('@', $email1); - $email2 = explode('@', $email2); - - $domain1 = array_pop($email1); - $domain2 = array_pop($email2); - - $email1 = implode('@', $email1) . '@' . mb_strtolower($domain1); - $email2 = implode('@', $email2) . '@' . mb_strtolower($domain2); - - return $email1 === $email2; -} |