lib/kolab_client_task.php lib/kolab_utils.php
Aleksander Machniak
machniak at kolabsys.com
Wed Jul 3 19:05:39 CEST 2013
lib/kolab_client_task.php | 2 +-
lib/kolab_utils.php | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
New commits:
commit 6d502c35f04970d1379a99c21d37f69723be67fc
Author: Aleksander Machniak <alec at alec.pl>
Date: Wed Jul 3 19:03:56 2013 +0200
Fix ldap_dn2ufn() output, so unicode characters are handled properly.
This fixes issue where unicode characters in OU selector were "encoded"
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index c334fdb..3f50b9d 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -923,7 +923,7 @@ class kolab_client_task
// Exceptions
if ($field['name'] == 'ou') {
foreach ($options as $idx => $dn) {
- $options[$idx] = ldap_dn2ufn($dn);
+ $options[$idx] = kolab_utils::dn2ufn($dn);
}
}
}
diff --git a/lib/kolab_utils.php b/lib/kolab_utils.php
index 2c4c2a0..9f064e3 100644
--- a/lib/kolab_utils.php
+++ b/lib/kolab_utils.php
@@ -154,4 +154,26 @@ class kolab_utils
return is_array($arr) && count(array_filter(array_keys($arr), 'is_string')) == count($arr);
}
+ /**
+ * Unicode-aware ldap_dn2ufn() wrapper
+ *
+ * @param string $dn LDAP DN string
+ *
+ * @return string Human-readable string
+ */
+ public static function dn2ufn($dn)
+ {
+ $name = ldap_dn2ufn($dn);
+ $pos = 0;
+
+ // example: "\C3\A4" => "ä"
+ while (preg_match('/\\\\[0-9a-fA-F]{2}/', $name, $matches, PREG_OFFSET_CAPTURE, $pos)) {
+ $char = chr(hexdec(substr($matches[0][0], 1)));
+ $pos = $matches[0][1];
+ $name = substr_replace($name, $char, $pos, 3);
+ $pos += 1;
+ }
+
+ return $name;
+ }
}
More information about the commits
mailing list