From f06aa8058b7e32ba32d4551074b6e0b8a300f751 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Mon, 21 Oct 2013 15:02:40 -0400
Subject: [PATCH] Bump version after security fix

---
 program/include/rcube_ldap.php |   59 ++++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php
index 174ee17..17ef20a 100644
--- a/program/include/rcube_ldap.php
+++ b/program/include/rcube_ldap.php
@@ -132,7 +132,7 @@
         if ($this->fieldmap['street'] && $this->fieldmap['locality']) {
             $this->coltypes['address'] = array(
                'limit'    => max(1, $this->coltypes['locality']['limit'] + $this->coltypes['address']['limit']),
-               'subtypes' => array_merge((array)$this->coltypes['address']['subtypes'], $this->coltypes['locality']['subtypes']),
+               'subtypes' => array_merge((array)$this->coltypes['address']['subtypes'], (array)$this->coltypes['locality']['subtypes']),
                'childs' => array(),
                ) + (array)$this->coltypes['address'];
 
@@ -142,9 +142,21 @@
                     unset($this->coltypes[$childcol]);  // remove address child col from global coltypes list
                 }
             }
+
+            // at least one address type must be specified
+            if (empty($this->coltypes['address']['subtypes'])) {
+                $this->coltypes['address']['subtypes'] = array('home');
+            }
         }
         else if ($this->coltypes['address']) {
-            $this->coltypes['address'] = array('type' => 'textarea', 'childs' => null, 'limit' => 1, 'size' => 40);
+            $this->coltypes['address'] += array('type' => 'textarea', 'childs' => null, 'size' => 40);
+
+            // 'serialized' means the UI has to present a composite address field
+            if ($this->coltypes['address']['serialized']) {
+                $childprop = array('type' => 'text');
+                $this->coltypes['address']['type'] = 'composite';
+                $this->coltypes['address']['childs'] = array('street' => $childprop, 'locality' => $childprop, 'zipcode' => $childprop, 'country' => $childprop);
+            }
         }
 
         // make sure 'required_fields' is an array
@@ -791,24 +803,26 @@
 
             for ($i = 0; $i < $entries['count']; $i++) {
                 $rec = $this->_ldap2result($entries[$i]);
-                foreach (array('email', 'name') as $f) {
-                    $val = mb_strtolower($rec[$f]);
-                    switch ($mode) {
-                    case 1:
-                        $got = ($val == $search);
-                        break;
-                    case 2:
-                        $got = ($search == substr($val, 0, strlen($search)));
-                        break;
-                    default:
-                        $got = (strpos($val, $search) !== false);
-                        break;
-                    }
+                foreach ($fields as $f) {
+                    foreach ((array)$rec[$f] as $val) {
+                        $val = mb_strtolower($val);
+                        switch ($mode) {
+                        case 1:
+                            $got = ($val == $search);
+                            break;
+                        case 2:
+                            $got = ($search == substr($val, 0, strlen($search)));
+                            break;
+                        default:
+                            $got = (strpos($val, $search) !== false);
+                            break;
+                        }
 
-                    if ($got) {
-                        $this->result->add($rec);
-                        $this->result->count++;
-                        break;
+                        if ($got) {
+                            $this->result->add($rec);
+                            $this->result->count++;
+                            break 2;
+                        }
                     }
                 }
             }
@@ -1187,8 +1201,11 @@
                     else if ($val == '') {
                         // Field supplied is empty, verify that it is not required.
                         if (!in_array($fld, $this->prop['required_fields'])) {
-                            // It is not, safe to clear.
-                            $deletedata[$fld] = $old_data[$fld];
+                            // ...It is not, safe to clear.
+                            // #1488420: Workaround "ldap_mod_del(): Modify: Inappropriate matching in..."
+                            // jpegPhoto attribute require an array() here. It looks to me that it works for other attribs too
+                            $deletedata[$fld] = array();
+                            //$deletedata[$fld] = $old_data[$fld];
                         }
                     }
                     else {

--
Gitblit v1.9.1