summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-10-24 08:59:26 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2014-10-24 08:59:26 (GMT)
commit88e47d7b395f01c0fd2f599ba38f455d1479380b (patch)
tree91168f0ece5661112a46b2b2b5d525d710723b69
parent5eb1c85b8b731ede3b8210f8fa26db3b4be3115d (diff)
downloadkolab-wap-88e47d7b395f01c0fd2f599ba38f455d1479380b.tar.gz
Skip invalid entries in autocompletion results to prevent js errors (#3822)
-rw-r--r--lib/api/kolab_api_service_form_value.php30
1 files changed, 22 insertions, 8 deletions
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;