lib/client

Aleksander Machniak machniak at kolabsys.com
Fri Oct 10 21:41:54 CEST 2014


 lib/client/kolab_client_task_ou.php |   45 +++++++++++++++++++++++++-----------
 1 file changed, 32 insertions(+), 13 deletions(-)

New commits:
commit 14b84021343d89f7f517709fc4d08b62f8f077d3
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Fri Oct 10 21:40:11 2014 +0200

    Fix handling special characters (e.g. comma) in organizational unit names (#3744)
    Fix escaping of object identifiers in javascript command (#3675) - for organizational units list

diff --git a/lib/client/kolab_client_task_ou.php b/lib/client/kolab_client_task_ou.php
index 6179518..a286d34 100644
--- a/lib/client/kolab_client_task_ou.php
+++ b/lib/client/kolab_client_task_ou.php
@@ -108,7 +108,7 @@ class kolab_client_task_ou extends kolab_client_task
             $cells[] = array(
                 'class'   => 'name',
                 'body'    => $tree . kolab_html::escape($item['name']),
-                'onclick' => "kadm.command('ou.info', '$idx')",
+                'onclick' => "kadm.command('ou.info', '" . kolab_utils::js_escape($idx) . "')",
             );
 
             $rows[] = array(
@@ -196,11 +196,8 @@ class kolab_client_task_ou extends kolab_client_task
     {
         // build the list for sorting
         foreach (array_keys($list) as $dn) {
-            $name = kolab_utils::dn2ufn($dn);
-            $name = explode(',', $name);
-
-            $sort_name = array_pop($name) . ',' . implode(',', array_reverse($name));
-
+            $names     = $this->explode_dn($dn);
+            $sort_name = $names['domain'] . ':' . implode(',', array_reverse($names['path']));
             $list[$dn] = mb_strtolower($sort_name);
         }
 
@@ -237,7 +234,10 @@ class kolab_client_task_ou extends kolab_client_task
                 $parent = $this->domain_dn($item['domain']);
 
                 foreach ($item['path'] as $sub) {
+                    // convert special characters back into entities (#
+                    $sub    = str_replace(',', "\\2C", $sub);
                     $parent = "ou=$sub,$parent";
+
                     if (!isset($result[$parent])) {
                         $result[$parent] = $this->parse_dn($parent);
                         $last = $parent;
@@ -260,15 +260,13 @@ class kolab_client_task_ou extends kolab_client_task
      */
     private function parse_dn($dn)
     {
-        $path   = kolab_utils::dn2ufn($dn);
-        $path   = explode(', ', $path);
-        $domain = array_pop($path); // remove domain
+        $items = $this->explode_dn($dn);
 
         return array(
-            'name'   => array_shift($path),
-            'path'   => array_reverse($path),
-            'level'  => count($path),
-            'domain' => $domain,
+            'name'   => array_shift($items['path']),
+            'path'   => array_reverse($items['path']),
+            'level'  => count($items['path']),
+            'domain' => $items['domain'],
         );
     }
 
@@ -279,4 +277,25 @@ class kolab_client_task_ou extends kolab_client_task
     {
         return "dc=" . implode(',dc=', explode('.', $domain));
     }
+
+    private function explode_dn($dn)
+    {
+        $path   = kolab_utils::explode_dn($dn);
+        $domain = array();
+
+        foreach ($path as $idx => $item) {
+            if (strpos($item, 'dc=') === 0) {
+                unset($path[$idx]);
+                $domain[] = substr($item, 3);
+            }
+            else {
+                $path[$idx] = substr($item, 3);
+            }
+        }
+
+        return array(
+            'domain' => implode('.', $domain),
+            'path'   => $path,
+        );
+    }
 }




More information about the commits mailing list