plugins/libkolab

Thomas Brüderli bruederli at kolabsys.com
Tue Jun 12 11:32:21 CEST 2012


 plugins/libkolab/lib/kolab_format_contact.php |    2 +-
 plugins/libkolab/lib/kolab_storage_folder.php |   17 ++++++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

New commits:
commit 40f811b33a0cf7b4ea6f66cdc34e161607f96ce4
Author: Thomas Bruederli <thomas at roundcube.net>
Date:   Tue Jun 12 11:30:13 2012 +0200

    Read X-Kolab-Mime-Version headers if available; Url::None => Url::NoType

diff --git a/plugins/libkolab/lib/kolab_format_contact.php b/plugins/libkolab/lib/kolab_format_contact.php
index 358e1b1..84df742 100644
--- a/plugins/libkolab/lib/kolab_format_contact.php
+++ b/plugins/libkolab/lib/kolab_format_contact.php
@@ -177,7 +177,7 @@ class kolab_format_contact extends kolab_format
 
         $vurls = new vectorurl;
         foreach ((array)$object['website'] as $url) {
-            $type = $url['type'] == 'blog' ? Url::Blog : Url::None;
+            $type = $url['type'] == 'blog' ? Url::Blog : Url::NoType;
             $vurls->push(new Url($url['url'], $type));
         }
         $this->obj->setUrls($vurls);
diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php
index ab5bfac..d2a78de 100644
--- a/plugins/libkolab/lib/kolab_storage_folder.php
+++ b/plugins/libkolab/lib/kolab_storage_folder.php
@@ -438,9 +438,20 @@ class kolab_storage_folder
             return false;
 
         // check kolab format version
-        list($xmltype, $subtype) = explode('.', $object_type);
-        if (strpos($xml, '<' . $xmltype) !== false && strpos($xml, 'xmlns=') === false) {
-            // old Kolab 2.0 format detected
+        $mime_version = $headers->others['x-kolab-mime-version'];
+        if (empty($mime_version)) {
+            list($xmltype, $subtype) = explode('.', $object_type);
+            $xmlhead = substr($xml, 0, 512);
+
+            // detect old Kolab 2.0 format
+            if (strpos($xmlhead, '<' . $xmltype) !== false && strpos($xmlhead, 'xmlns=') === false)
+                $mime_version = 2.0;
+            else
+                $mime_version = 3.0; // assume 3.0
+        }
+
+        if ($mime_version <= 2.0) {
+            // read Kolab 2.0 format
             $handler = class_exists('Horde_Kolab_Format') ? Horde_Kolab_Format::factory('XML', $xmltype, array('subtype' => $subtype)) : null;
             if (!is_object($handler) || is_a($handler, 'PEAR_Error')) {
                 return false;





More information about the commits mailing list