lib/api
Aleksander Machniak
machniak at kolabsys.com
Fri Oct 24 11:00:23 CEST 2014
lib/api/kolab_api_service_form_value.php | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
New commits:
commit 88e47d7b395f01c0fd2f599ba38f455d1479380b
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Fri Oct 24 04:59:26 2014 -0400
Skip invalid entries in autocompletion results to prevent js errors (#3822)
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 9a9bff2..e9e3a16 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -1304,15 +1304,23 @@ class kolab_api_service_form_value extends kolab_api_service
foreach ($list as $idx => $value) {
if (!empty($value['displayname'])) {
$list[$idx] = $value['displayname'];
- } elseif (!empty($value['cn'])) {
+ }
+ else if (!empty($value['cn'])) {
$list[$idx] = $value['cn'];
- } else {
- //console("No display name or cn for $idx");
+ }
+ else {
+ $list[$idx] = '';
}
if (!empty($value['mail'])) {
$list[$idx] .= ' <' . $value['mail'] . '>';
}
+
+ $list[$idx] = trim($list[$idx]);
+
+ if ($list[$idx] === '') {
+ unset($list[$idx]);
+ }
}
// Sort and slice
@@ -1367,7 +1375,12 @@ class kolab_api_service_form_value extends kolab_api_service
$idx = $value[$result_key];
}
- $result[$idx] = $ret;
+ $ret = trim($ret);
+
+ // sanity check (#3822)
+ if ($ret !== '') {
+ $result[$idx] = $ret;
+ }
}
return $result;
@@ -1406,12 +1419,13 @@ class kolab_api_service_form_value extends kolab_api_service
foreach ($list as $idx => $value) {
if (!empty($value['displayname'])) {
$list[$idx] = $value['displayname'];
- } elseif (!empty($value['cn'])) {
+ }
+ elseif (!empty($value['cn'])) {
$list[$idx] = $value['cn'];
- } else {
- //console("No display name or cn for $idx");
}
-
+ else {
+ unset($list[$idx]);
+ }
}
return $list;
More information about the commits
mailing list