]> source.dussan.org Git - nextcloud-server.git/commitdiff
update sabredav to 1.5.3
authorRobin Appelman <icewind1991@gmail.com>
Thu, 29 Sep 2011 12:28:57 +0000 (14:28 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Thu, 29 Sep 2011 12:28:57 +0000 (14:28 +0200)
29 files changed:
3rdparty/Sabre/CalDAV/Backend/Abstract.php
3rdparty/Sabre/CalDAV/Backend/PDO.php
3rdparty/Sabre/CalDAV/Calendar.php
3rdparty/Sabre/CalDAV/CalendarObject.php
3rdparty/Sabre/CalDAV/ICalendar.php [new file with mode: 0644]
3rdparty/Sabre/CalDAV/ICalendarObject.php [new file with mode: 0644]
3rdparty/Sabre/CalDAV/Plugin.php
3rdparty/Sabre/CalDAV/Version.php
3rdparty/Sabre/CardDAV/AddressBook.php
3rdparty/Sabre/CardDAV/Backend/PDO.php
3rdparty/Sabre/CardDAV/Card.php
3rdparty/Sabre/CardDAV/Plugin.php
3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php [new file with mode: 0644]
3rdparty/Sabre/CardDAV/Version.php
3rdparty/Sabre/DAV/Browser/Plugin.php
3rdparty/Sabre/DAV/Server.php
3rdparty/Sabre/DAV/SimpleFile.php [new file with mode: 0644]
3rdparty/Sabre/DAV/StringUtil.php
3rdparty/Sabre/DAV/URLUtil.php
3rdparty/Sabre/DAV/Version.php
3rdparty/Sabre/DAVACL/Principal.php
3rdparty/Sabre/DAVACL/Version.php
3rdparty/Sabre/HTTP/Response.php
3rdparty/Sabre/HTTP/Version.php
3rdparty/Sabre/VObject/Element/DateTime.php
3rdparty/Sabre/VObject/Element/MultiDateTime.php
3rdparty/Sabre/VObject/Property.php
3rdparty/Sabre/VObject/Reader.php
3rdparty/Sabre/VObject/Version.php

index 7ac282f44a0f70b08d00c5128ba5a73e2a8b7ee1..b694eef49e4696aa470cf56bc126c2bd1b273378 100644 (file)
@@ -36,20 +36,17 @@ abstract class Sabre_CalDAV_Backend_Abstract {
      * If the creation was a success, an id must be returned that can be used to reference
      * this calendar in other methods, such as updateCalendar.
      *
-     * This function must return a server-wide unique id that can be used 
-     * later to reference the calendar.
-     *
      * @param string $principalUri
      * @param string $calendarUri
      * @param array $properties
-     * @return string|int 
+     * @return void 
      */
     abstract function createCalendar($principalUri,$calendarUri,array $properties); 
 
     /**
-     * Updates properties on this node,
+     * Updates properties for a calendar.
      *
-     * The properties array uses the propertyName in clark-notation as key,
+     * The mutations array uses the propertyName in clark-notation as key,
      * and the array value for the property value. In the case a property
      * should be deleted, the property value will be null.
      *
@@ -79,10 +76,10 @@ abstract class Sabre_CalDAV_Backend_Abstract {
      * (424 Failed Dependency) because the request needs to be atomic.
      *
      * @param string $calendarId
-     * @param array $properties
+     * @param array $mutations
      * @return bool|array 
      */
-    public function updateCalendar($calendarId, array $properties) {
+    public function updateCalendar($calendarId, array $mutations) {
         
         return false; 
 
@@ -97,7 +94,7 @@ abstract class Sabre_CalDAV_Backend_Abstract {
     abstract function deleteCalendar($calendarId);
 
     /**
-     * Returns all calendar objects within a calendar object.
+     * Returns all calendar objects within a calendar.
      *
      * Every item contains an array with the following keys:
      *   * id - unique identifier which will be used for subsequent updates
index d1785bb8f8fc162d9f10c8fb7abad0b2409e8102..7b1b33b912ee53a4fd4a94febccbcb6b4c871141 100644 (file)
@@ -129,7 +129,6 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
      * @param string $principalUri
      * @param string $calendarUri
      * @param array $properties
-     * @return mixed
      */
     public function createCalendar($principalUri,$calendarUri, array $properties) {
 
@@ -173,9 +172,9 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
     }
 
     /**
-     * Updates a calendars properties 
+     * Updates properties for a calendar.
      *
-     * The properties array uses the propertyName in clark-notation as key,
+     * The mutations array uses the propertyName in clark-notation as key,
      * and the array value for the property value. In the case a property
      * should be deleted, the property value will be null.
      *
@@ -205,10 +204,10 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
      * (424 Failed Dependency) because the request needs to be atomic.
      *
      * @param string $calendarId
-     * @param array $properties
+     * @param array $mutations 
      * @return bool|array 
      */
-    public function updateCalendar($calendarId, array $properties) {
+    public function updateCalendar($calendarId, array $mutations) {
 
         $newValues = array();
         $result = array(
@@ -219,13 +218,13 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
 
         $hasError = false;
 
-        foreach($properties as $propertyName=>$propertyValue) {
+        foreach($mutations as $propertyName=>$propertyValue) {
 
             // We don't know about this property. 
             if (!isset($this->propertyMap[$propertyName])) {
                 $hasError = true;
                 $result[403][$propertyName] = null;
-                unset($properties[$propertyName]);
+                unset($mutations[$propertyName]);
                 continue;
             }
 
@@ -237,7 +236,7 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
         // If there were any errors we need to fail the request
         if ($hasError) {
             // Properties has the remaining properties
-            foreach($properties as $propertyName=>$propertyValue) {
+            foreach($mutations as $propertyName=>$propertyValue) {
                 $result[424][$propertyName] = null;
             }
 
@@ -284,7 +283,7 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
     }
 
     /**
-     * Returns all calendar objects within a calendar object.
+     * Returns all calendar objects within a calendar
      *
      * Every item contains an array with the following keys:
      *   * id - unique identifier which will be used for subsequent updates
index a50aef12b4f6fc4e4515e211efa15f0e46c6bc3e..0d2b3875771729f323e8f19cc86a2376eb77b6d6 100644 (file)
@@ -12,7 +12,7 @@
  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-class Sabre_CalDAV_Calendar implements Sabre_DAV_ICollection, Sabre_DAV_IProperties, Sabre_DAVACL_IACL {
+class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProperties, Sabre_DAVACL_IACL {
 
     /**
      * This is an array with calendar information 
@@ -178,6 +178,8 @@ class Sabre_CalDAV_Calendar implements Sabre_DAV_ICollection, Sabre_DAV_IPropert
     public function createFile($name,$calendarData = null) {
 
         $calendarData = stream_get_contents($calendarData);
+        // Converting to UTF-8, if needed
+        $calendarData = Sabre_DAV_StringUtil::ensureUTF8($calendarData);
 
         $supportedComponents = $this->calendarInfo['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set'];
         if ($supportedComponents) {
index b5c4e49b838ce669eac8cd74a3b82491c05e3f65..0c99f18deb72cca5233bd50ffdce28bd3037fc86 100644 (file)
@@ -9,7 +9,7 @@
  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_DAVACL_IACL {
+class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_CalDAV_ICalendarObject, Sabre_DAVACL_IACL {
 
     /**
      * Sabre_CalDAV_Backend_Abstract 
@@ -93,6 +93,9 @@ class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_DAVACL
         if (is_resource($calendarData))
             $calendarData = stream_get_contents($calendarData);
 
+        // Converting to UTF-8, if needed
+        $calendarData = Sabre_DAV_StringUtil::ensureUTF8($calendarData);
+
         $supportedComponents = $this->calendarInfo['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set'];
         if ($supportedComponents) {
             $supportedComponents = $supportedComponents->getValue();
diff --git a/3rdparty/Sabre/CalDAV/ICalendar.php b/3rdparty/Sabre/CalDAV/ICalendar.php
new file mode 100644 (file)
index 0000000..8193dff
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+/**
+ * Calendar interface
+ *
+ * Implement this interface to allow a node to be recognized as an calendar.
+ * 
+ * @package Sabre
+ * @subpackage CalDAV
+ * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
+ * @author Evert Pot (http://www.rooftopsolutions.nl/) 
+ * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
+ */
+interface Sabre_CalDAV_ICalendar extends Sabre_DAV_ICollection {
+
+
+}
diff --git a/3rdparty/Sabre/CalDAV/ICalendarObject.php b/3rdparty/Sabre/CalDAV/ICalendarObject.php
new file mode 100644 (file)
index 0000000..708300a
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * CalendarObject interface 
+/**
+ * Extend the ICalendarObject interface to allow your custom nodes to be picked up as 
+ * CalendarObjects.
+ *
+ * Calendar objects are resources such as Events, Todo's or Journals.
+ * 
+ * @package Sabre
+ * @subpackage CalDAV
+ * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
+ * @author Evert Pot (http://www.rooftopsolutions.nl/) 
+ * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
+ */
+interface Sabre_CalDAV_ICalendarObject extends Sabre_DAV_IFile { 
+
+}
+
index 640595e74babca337367fecbbed63e4336f391fa..02747c8395e3a2b6d0f32183074d598d707ffff6 100644 (file)
@@ -114,7 +114,7 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin {
     public function getSupportedReportSet($uri) {
 
         $node = $this->server->tree->getNodeForPath($uri);
-        if ($node instanceof Sabre_CalDAV_Calendar || $node instanceof Sabre_CalDAV_CalendarObject) {
+        if ($node instanceof Sabre_CalDAV_ICalendar || $node instanceof Sabre_CalDAV_ICalendarObject) {
             return array(
                  '{' . self::NS_CALDAV . '}calendar-multiget',
                  '{' . self::NS_CALDAV . '}calendar-query',
@@ -143,7 +143,7 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin {
 
         $server->propertyMap['{' . self::NS_CALDAV . '}supported-calendar-component-set'] = 'Sabre_CalDAV_Property_SupportedCalendarComponentSet';
 
-        $server->resourceTypeMapping['Sabre_CalDAV_Calendar'] = '{urn:ietf:params:xml:ns:caldav}calendar';
+        $server->resourceTypeMapping['Sabre_CalDAV_ICalendar'] = '{urn:ietf:params:xml:ns:caldav}calendar';
         $server->resourceTypeMapping['Sabre_CalDAV_Principal_ProxyRead'] = '{http://calendarserver.org/ns/}calendar-proxy-read';
         $server->resourceTypeMapping['Sabre_CalDAV_Principal_ProxyWrite'] = '{http://calendarserver.org/ns/}calendar-proxy-write';
 
@@ -326,7 +326,7 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin {
         } // instanceof IPrincipal
 
 
-        if ($node instanceof Sabre_CalDAV_CalendarObject) {
+        if ($node instanceof Sabre_CalDAV_ICalendarObject) {
             // The calendar-data property is not supposed to be a 'real' 
             // property, but in large chunks of the spec it does act as such. 
             // Therefore we simply expose it as a property.
index 5ecc0cebb376dc335244eff37ef8e5b35982c1f5..df8fe1f6bd6fba8d724939a0ed3d9fe18014fac4 100644 (file)
@@ -14,7 +14,7 @@ class Sabre_CalDAV_Version {
     /**
      * Full version number
      */
-    const VERSION = '1.5.0';
+    const VERSION = '1.5.3';
 
     /**
      * Stability : alpha, beta, stable
index 04e4c227b86574104449a77d237893560698da51..3333480ea8549f4da860127a240c375cf2ca6c10 100644 (file)
@@ -112,6 +112,8 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
     public function createFile($name,$vcardData = null) {
 
         $vcardData = stream_get_contents($vcardData);
+        // Converting to UTF-8, if needed
+        $vcardData = Sabre_DAV_StringUtil::ensureUTF8($vcardData);
 
         $this->carddavBackend->createCard($this->addressBookInfo['id'],$name,$vcardData);
 
index 63a74745aaca8c18a8f9132f442b4cbc5e339fa0..5556d0a7648f1dcf0211afdd7899c03507e20cdd 100644 (file)
@@ -66,7 +66,9 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
                 'principaluri' => $row['principaluri'],
                 '{DAV:}displayname' => $row['displayname'],
                 '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
-                '{http://calendarserver.org/ns/}getctag' => $row['ctag'], 
+                '{http://calendarserver.org/ns/}getctag' => $row['ctag'],
+                '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' => 
+                    new Sabre_CardDAV_Property_SupportedAddressData(),
             );
 
         }
index 52d8b79d7ddbc27914c432e79bbbf42089ce4f14..5298d31e2455f55fccb44b97c00b1cf53140cb61 100644 (file)
@@ -88,6 +88,9 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
         if (is_resource($cardData))
             $cardData = stream_get_contents($cardData);
 
+        // Converting to UTF-8, if needed
+        $cardData = Sabre_DAV_StringUtil::ensureUTF8($cardData);
+
         $this->carddavBackend->updateCard($this->addressBookInfo['id'],$this->cardData['uri'],$cardData);
         $this->cardData['carddata'] = $cardData;
 
index a96f9aaebb6872be472ab4f4861f1cc611d8213f..17766b78278c84a14cb530880078ca04ac85ad9c 100644 (file)
@@ -95,9 +95,10 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
     public function getSupportedReportSet($uri) {
 
         $node = $this->server->tree->getNodeForPath($uri);
-        if ($node instanceof Sabre_CardDAV_AddressBook || $node instanceof Sabre_CardDAV_ICard) {
+        if ($node instanceof Sabre_CardDAV_IAddressBook || $node instanceof Sabre_CardDAV_ICard) {
             return array(
                  '{' . self::NS_CARDDAV . '}addressbook-multiget',
+                 '{' . self::NS_CARDDAV . '}addressbook-query',
             );
         }
         return array();
diff --git a/3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php b/3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php
new file mode 100644 (file)
index 0000000..d57d3a6
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+
+/**
+ * Supported-address-data property
+ *
+ * This property is a representation of the supported-address-data property
+ * in the CardDAV namespace. 
+ *
+ * @package Sabre
+ * @subpackage CardDAV
+ * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
+ * @author Evert Pot (http://www.rooftopsolutions.nl/) 
+ * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
+ */
+class Sabre_CardDAV_Property_SupportedAddressData extends Sabre_DAV_Property {
+
+    /**
+     * supported versions
+     * 
+     * @var array 
+     */
+    protected $supportedData = array();
+    
+    /**
+     * Creates the property 
+     * 
+     * @param array $components 
+     */
+    public function __construct(array $supportedData = null) {
+
+        if (is_null($supportedData)) {
+            $supportedData = array(
+                array('contentType' => 'text/vcard', 'version' => '3.0'),
+                array('contentType' => 'text/vcard', 'version' => '4.0'),
+            );
+        }
+
+       $this->supportedData = $supportedData; 
+
+    }
+    
+    /**
+     * Serializes the property in a DOMDocument 
+     * 
+     * @param Sabre_DAV_Server $server 
+     * @param DOMElement $node 
+     * @return void
+     */
+    public function serialize(Sabre_DAV_Server $server,DOMElement $node) {
+
+        $doc = $node->ownerDocument;
+
+        $prefix = 
+            isset($server->xmlNamespaces[Sabre_CardDAV_Plugin::NS_CARDDAV]) ?
+            $server->xmlNamespaces[Sabre_CardDAV_Plugin::NS_CARDDAV] :
+            'card';
+
+        foreach($this->supportedData as $supported) {
+
+            $caldata = $doc->createElementNS(Sabre_CardDAV_Plugin::NS_CARDDAV, $prefix . ':address-data-type');
+            $caldata->setAttribute('content-type',$supported['contentType']);
+            $caldata->setAttribute('version',$supported['version']);
+            $node->appendChild($caldata);
+
+        }
+
+    }
+
+}
index 8961027fc89a0b0d95e64e8720243ae59a275190..c76ee3603547f3ff0be211dc613e13809cca8ddb 100644 (file)
@@ -18,11 +18,11 @@ class Sabre_CardDAV_Version {
     /**
      * Full version number
      */
-    const VERSION = '0.2';
+    const VERSION = '1.5.3';
 
     /**
      * Stability : alpha, beta, stable
      */
-    const STABILITY = 'alpha';
+    const STABILITY = 'stable';
 
 }
index 8e0ca24cff25176fcb96d021e013c13f272f653a..cd5617babb160819ad04d72cb4cc48c27c3fad99 100644 (file)
@@ -68,9 +68,16 @@ class Sabre_DAV_Browser_Plugin extends Sabre_DAV_ServerPlugin {
     public function httpGetInterceptor($method, $uri) {
 
         if ($method!='GET') return true;
-        
-        $node = $this->server->tree->getNodeForPath($uri);
-        if ($node instanceof Sabre_DAV_IFile) return true;
+
+        try { 
+            $node = $this->server->tree->getNodeForPath($uri);
+        } catch (Sabre_DAV_Exception_FileNotFound $e) {
+            // We're simply stopping when the file isn't found to not interfere 
+            // with other plugins.
+            return;
+        }
+        if ($node instanceof Sabre_DAV_IFile) 
+            return;
 
         $this->server->httpResponse->sendStatus(200);
         $this->server->httpResponse->setHeader('Content-Type','text/html; charset=utf-8');
@@ -165,6 +172,8 @@ class Sabre_DAV_Browser_Plugin extends Sabre_DAV_ServerPlugin {
         '{DAV:}getlastmodified',
     ),1);
 
+    $parent = $this->server->tree->getNodeForPath($path);
+
 
     if ($path) {
 
@@ -189,6 +198,7 @@ class Sabre_DAV_Browser_Plugin extends Sabre_DAV_ServerPlugin {
 
         $type = null;
 
+
         if (isset($file[200]['{DAV:}resourcetype'])) {
             $type = $file[200]['{DAV:}resourcetype']->getValue();
 
@@ -246,7 +256,7 @@ class Sabre_DAV_Browser_Plugin extends Sabre_DAV_ServerPlugin {
 
   $html.= "<tr><td colspan=\"4\"><hr /></td></tr>";
 
-  if ($this->enablePost) {
+  if ($this->enablePost && $parent instanceof Sabre_DAV_ICollection) {
       $html.= '<tr><td><form method="post" action="">
             <h3>Create new folder</h3>
             <input type="hidden" name="sabreAction" value="mkcol" />
index c6c63143d13572c0b1487f429d23b7246b1266b0..b99866dad5e12b1404795694be3d3dbe1dab4cb2 100644 (file)
@@ -738,6 +738,34 @@ class Sabre_DAV_Server {
 
         $body = $this->httpRequest->getBody();
 
+        // Intercepting Content-Range
+        if ($this->httpRequest->getHeader('Content-Range')) {
+            /**
+            Content-Range is dangerous for PUT requests:  PUT per definition
+            stores a full resource.  draft-ietf-httpbis-p2-semantics-15 says
+            in section 7.6:
+              An origin server SHOULD reject any PUT request that contains a
+              Content-Range header field, since it might be misinterpreted as
+              partial content (or might be partial content that is being mistakenly
+              PUT as a full representation).  Partial content updates are possible
+              by targeting a separately identified resource with state that
+              overlaps a portion of the larger resource, or by using a different
+              method that has been specifically defined for partial updates (for
+              example, the PATCH method defined in [RFC5789]).
+            This clarifies RFC2616 section 9.6:
+              The recipient of the entity MUST NOT ignore any Content-*
+              (e.g. Content-Range) headers that it does not understand or implement
+              and MUST return a 501 (Not Implemented) response in such cases.
+            OTOH is a PUT request with a Content-Range currently the only way to
+            continue an aborted upload request and is supported by curl, mod_dav,
+            Tomcat and others.  Since some clients do use this feature which results
+            in unexpected behaviour (cf PEAR::HTTP_WebDAV_Client 1.0.1), we reject
+            all PUT requests with a Content-Range for now.
+            */
+
+            throw new Sabre_DAV_Exception_NotImplemented('PUT with Content-Range is not allowed.');
+        }
+
         // Intercepting the Finder problem
         if (($expected = $this->httpRequest->getHeader('X-Expected-Entity-Length')) && $expected > 0) {
            
@@ -798,7 +826,10 @@ class Sabre_DAV_Server {
         } else {
 
             // If we got here, the resource didn't exist yet.
-            $this->createFile($this->getRequestUri(),$body);
+            if (!$this->createFile($this->getRequestUri(),$body)) {
+                // For one reason or another the file was not created.
+                return;
+            }
             $this->httpResponse->setHeader('Content-Length','0');
             $this->httpResponse->sendStatus(201);
 
@@ -1377,23 +1408,27 @@ class Sabre_DAV_Server {
      * Currently this is done by HTTP PUT and HTTP LOCK (in the Locks_Plugin).
      * It was important to get this done through a centralized function, 
      * allowing plugins to intercept this using the beforeCreateFile event.
+     *
+     * This method will return true if the file was actually created
      * 
      * @param string $uri 
      * @param resource $data 
-     * @return void
+     * @return bool 
      */
     public function createFile($uri,$data) {
 
         list($dir,$name) = Sabre_DAV_URLUtil::splitPath($uri);
 
-        if (!$this->broadcastEvent('beforeBind',array($uri))) return;
-        if (!$this->broadcastEvent('beforeCreateFile',array($uri,$data))) return;
+        if (!$this->broadcastEvent('beforeBind',array($uri))) return false;
+        if (!$this->broadcastEvent('beforeCreateFile',array($uri,$data))) return false;
 
         $parent = $this->tree->getNodeForPath($dir);
         $parent->createFile($name,$data);
         $this->tree->markDirty($dir);
 
         $this->broadcastEvent('afterBind',array($uri));
+
+        return true;
     }
 
     /**
diff --git a/3rdparty/Sabre/DAV/SimpleFile.php b/3rdparty/Sabre/DAV/SimpleFile.php
new file mode 100644 (file)
index 0000000..304dff1
--- /dev/null
@@ -0,0 +1,120 @@
+<?php
+
+/**
+ * SimpleFile
+ *
+ * The 'SimpleFile' class is used to easily add read-only immutable files to 
+ * the directory structure. One usecase would be to add a 'readme.txt' to a 
+ * root of a webserver with some standard content.
+ *
+ * @package Sabre
+ * @subpackage DAV
+ * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
+ * @author Evert Pot (http://www.rooftopsolutions.nl/) 
+ * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
+ */
+class Sabre_DAV_SimpleFile extends Sabre_DAV_File {
+
+    /**
+     * File contents 
+     *
+     * @var string 
+     */
+    protected $contents = array();
+
+    /**
+     * Name of this resource 
+     * 
+     * @var string 
+     */
+    protected $name;
+
+    /**
+     * A mimetype, such as 'text/plain' or 'text/html'
+     * 
+     * @var string 
+     */
+    protected $mimeType;
+
+    /**
+     * Creates this node
+     *
+     * The name of the node must be passed, as well as the contents of the 
+     * file.
+     * 
+     * @param string $name 
+     * @param string $contents 
+     */
+    public function __construct($name, $contents, $mimeType = null) {
+
+        $this->name = $name;
+        $this->contents = $contents;
+        $this->mimeType = $mimeType;
+
+    }
+
+    /**
+     * Returns the node name for this file.
+     *
+     * This name is used to construct the url.
+     * 
+     * @return string 
+     */
+    public function getName() {
+
+        return $this->name;
+
+    }
+
+    /**
+     * Returns the data 
+     *
+     * This method may either return a string or a readable stream resource
+     *
+     * @return mixed
+     */
+    public function get() {
+
+        return $this->contents; 
+
+    }
+
+    /**
+     * Returns the size of the file, in bytes. 
+     * 
+     * @return int 
+     */
+    public function getSize() {
+
+        return strlen($this->contents);
+
+    }
+
+    /**
+     * Returns the ETag for a file
+     *
+     * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.
+     * The ETag is an arbritrary string, but MUST be surrounded by double-quotes.
+     *
+     * Return null if the ETag can not effectively be determined
+     */
+    public function getETag() {
+
+        return '"' . md5($this->contents) . '"'; 
+
+    }
+
+    /**
+     * Returns the mime-type for a file
+     *
+     * If null is returned, we'll assume application/octet-stream
+     */ 
+    public function getContentType() {
+
+        return $this->mimeType; 
+
+    }
+
+}
+
+?>
index b0b708f8e0f10e66da85be97bc076cd5ee6fbb3d..440cf6866ca6a68d5b8e7f2356342db961468b27 100644 (file)
@@ -64,6 +64,27 @@ class Sabre_DAV_StringUtil {
 
         }
         
+    }
+
+    /**
+     * This method takes an input string, checks if it's not valid UTF-8 and 
+     * attempts to convert it to UTF-8 if it's not.
+     *
+     * Note that currently this can only convert ISO-8559-1 to UTF-8 (latin-1), 
+     * anything else will likely fail.
+     *
+     * @param string $input 
+     * @return string 
+     */
+    static public function ensureUTF8($input) {
+
+        $encoding = mb_detect_encoding($input , array('UTF-8','ISO-8859-1'), true);
+
+        if ($encoding === 'ISO-8859-1') {
+            return utf8_encode($input);
+        } else {
+            return $input;
+        } 
 
     }
 
index 1502e4dd2cea38d652f1038bbb9a9bdbf3b46ee2..8f38749264b1f5e3c5b87ec0195f05aa749dbee2 100644 (file)
@@ -30,9 +30,14 @@ class Sabre_DAV_URLUtil {
      */
     static function encodePath($path) {
 
-        $path = explode('/',$path);
-        return implode('/',array_map(array('Sabre_DAV_URLUtil','encodePathSegment'), $path));
-
+       $valid_chars = '/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-.~()';
+        $newStr = '';
+        for( $i=0; isset($path[$i]); ++$i ) {
+            if( strpos($valid_chars,($c=$path[$i]))===false ) $newStr .= '%'.sprintf('%02x',ord($c));
+            else $newStr .= $c;
+        }
+        return $newStr;
+       
     }
 
     /**
@@ -45,35 +50,13 @@ class Sabre_DAV_URLUtil {
      */
     static function encodePathSegment($pathSegment) {
 
+       $valid_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-.~()';
         $newStr = '';
-        for($i=0;$i<strlen($pathSegment);$i++) {
-            $c = ord($pathSegment[$i]);
-
-            if(
-                
-                /* Unreserved chacaters */
-
-                ($c>=0x41 /* A */ && $c<=0x5a /* Z */) ||
-                ($c>=0x61 /* a */ && $c<=0x7a /* z */) ||
-                ($c>=0x30 /* 0 */ && $c<=0x39 /* 9 */) ||
-                $c===0x5f /* _ */ ||
-                $c===0x2d /* - */ ||
-                $c===0x2e /* . */ ||
-                $c===0x7E /* ~ */ ||
-
-                /* Reserved, but no reserved purpose */
-                $c===0x28 /* ( */ ||
-                $c===0x29 /* ) */
-
-            ) { 
-                $newStr.=$pathSegment[$i];
-            } else {
-                $newStr.='%' . str_pad(dechex($c), 2, '0', STR_PAD_LEFT);
-            }
-                
+        for( $i=0; isset($pathSegment[$i]); ++$i ) {
+            if( strpos($valid_chars,($c=$pathSegment[$i]))===false ) $newStr .= '%'.sprintf('%02x',ord($c));
+            else $newStr .= $c;
         }
         return $newStr;
-
     }
 
     /**
@@ -103,6 +86,7 @@ class Sabre_DAV_URLUtil {
 
             case 'ISO-8859-1' : 
                 $path = utf8_encode($path);
+
         }
 
         return $path;
index c93d793ab672d3bb1f48d5826d420208b99d74ce..e7f7f83e6fffa9b1c1874e0fec4b123f9df30665 100644 (file)
@@ -14,11 +14,11 @@ class Sabre_DAV_Version {
     /**
      * Full version number
      */
-    const VERSION = '1.5.0';
+    const VERSION = '1.5.3';
 
     /**
      * Stability : alpha, beta, stable
      */
-    const STABILITY = 'alpha';
+    const STABILITY = 'stable';
 
 }
index 158b271058c704246667c696087d920db3e40516..790603c900f33f3361bcab9cdbea308744dd1383 100644 (file)
@@ -68,12 +68,19 @@ class Sabre_DAVACL_Principal extends Sabre_DAV_Node implements Sabre_DAVACL_IPri
      */
     public function getAlternateUriSet() {
 
+        $uris = array();
+        if (isset($this->principalProperties['{DAV:}alternate-URI-set'])) {
+
+            $uris = $this->principalProperties['{DAV:}alternate-URI-set'];
+
+        }
+
         if (isset($this->principalProperties['{http://sabredav.org/ns}email-address'])) {
-            return array('mailto:' . $this->principalProperties['{http://sabredav.org/ns}email-address']);
-        } else {
-            return array();
+            $uris[] = 'mailto:' . $this->principalProperties['{http://sabredav.org/ns}email-address'];
         }
 
+        return array_unique($uris); 
+
     }
 
     /**
index a705507486c24c74600aa2298d02a211f1dd581e..124463e311e1c04d01acbc1f9da56e5d6d38bc4e 100644 (file)
@@ -14,7 +14,7 @@ class Sabre_DAVACL_Version {
     /**
      * Full version number
      */
-    const VERSION = '1.4.4';
+    const VERSION = '1.5.2';
 
     /**
      * Stability : alpha, beta, stable
index c8c77251a178dee2bfd5a6e0a1e3eeafcb4be285..dce6feac55336bab4e20ac6ed00c3ed5edd48c5f 100644 (file)
@@ -23,7 +23,7 @@ class Sabre_HTTP_Response {
             100 => 'Continue',
             101 => 'Switching Protocols',
             102 => 'Processing',
-            200 => 'Ok',
+            200 => 'OK',
             201 => 'Created',
             202 => 'Accepted',
             203 => 'Non-Authorative Information',
index f8d1bb754293225ac8e95e6da8b1faef429a7e25..67be232fc26b4ce1ec0519775995ebf25bb4ff2b 100644 (file)
@@ -14,7 +14,7 @@ class Sabre_HTTP_Version {
     /**
      * Full version number
      */
-    const VERSION = '1.4.1';
+    const VERSION = '1.5.3';
 
     /**
      * Stability : alpha, beta, stable
index 30e5c6ca86a0695cec99e0a8ab99dbcdf593d475..63af858dd68ff60a21e9b3ae03ce85853be8c2a5 100644 (file)
@@ -70,20 +70,20 @@ class Sabre_VObject_Element_DateTime extends Sabre_VObject_Property {
                 $this->setValue($dt->format('Ymd\\THis'));
                 $this->offsetUnset('VALUE');
                 $this->offsetUnset('TZID');
-                $this->offsetSet('VALUE','DATE-TIME');
+                $this->offsetSet('VALUE','DATETIME'); 
                 break;
             case self::UTC :
                 $dt->setTimeZone(new DateTimeZone('UTC'));
                 $this->setValue($dt->format('Ymd\\THis\\Z'));
                 $this->offsetUnset('VALUE');
                 $this->offsetUnset('TZID');
-                $this->offsetSet('VALUE','DATE-TIME');
+                $this->offsetSet('VALUE','DATETIME');
                 break;
             case self::LOCALTZ :
                 $this->setValue($dt->format('Ymd\\THis'));
                 $this->offsetUnset('VALUE');
                 $this->offsetUnset('TZID');
-                $this->offsetSet('VALUE','DATE-TIME');
+                $this->offsetSet('VALUE','DATETIME');
                 $this->offsetSet('TZID', $dt->getTimeZone()->getName());
                 break; 
             case self::DATE :
index 5e677f5e5b5feab9f3968f9c925d61675269c3fc..07f7e82c3467201f3fc7271e76ba4c454394b7ce 100644 (file)
@@ -60,7 +60,7 @@ class Sabre_VObject_Element_MultiDateTime extends Sabre_VObject_Property {
                     $val[] = $i->format('Ymd\\THis');
                 }
                 $this->setValue(implode(',',$val));
-                $this->offsetSet('VALUE','DATE-TIME');
+                $this->offsetSet('VALUE','DATETIME'); 
                 break;
             case Sabre_VObject_Element_DateTime::UTC :
                 $val = array();
@@ -69,7 +69,7 @@ class Sabre_VObject_Element_MultiDateTime extends Sabre_VObject_Property {
                     $val[] = $i->format('Ymd\\THis\\Z');
                 }
                 $this->setValue(implode(',',$val));
-                $this->offsetSet('VALUE','DATE-TIME');
+                $this->offsetSet('VALUE','DATETIME');
                 break;
             case Sabre_VObject_Element_DateTime::LOCALTZ :
                 $val = array();
@@ -77,7 +77,7 @@ class Sabre_VObject_Element_MultiDateTime extends Sabre_VObject_Property {
                     $val[] = $i->format('Ymd\\THis');
                 }
                 $this->setValue(implode(',',$val));
-                $this->offsetSet('VALUE','DATE-TIME');
+                $this->offsetSet('VALUE','DATETIME');
                 $this->offsetSet('TZID', $dt[0]->getTimeZone()->getName());
                 break; 
             case Sabre_VObject_Element_DateTime::DATE :
index 201e6356ad6c09adb6af1ac53da26db5fc8cc8c4..624dd4b8a58e3fe2398e0295f8431a34384792d2 100644 (file)
@@ -128,6 +128,44 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
 
     }
 
+    /**
+     * Adds a new componenten or element
+     *
+     * You can call this method with the following syntaxes:
+     *
+     * add(Sabre_VObject_Parameter $element)
+     * add(string $name, $value)
+     *
+     * The first version adds an Parameter 
+     * The second adds a property as a string. 
+     * 
+     * @param mixed $item 
+     * @param mixed $itemValue 
+     * @return void
+     */
+    public function add($item, $itemValue = null) {
+
+        if ($item instanceof Sabre_VObject_Parameter) {
+            if (!is_null($itemValue)) {
+                throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject');
+            }
+            $this->parameters[] = $item;
+        } elseif(is_string($item)) {
+
+            if (!is_scalar($itemValue)) {
+                throw new InvalidArgumentException('The second argument must be scalar');
+            }
+            $this->parameters[] = new Sabre_VObject_Parameter($item,$itemValue);
+
+        } else {
+            
+            throw new InvalidArgumentException('The first argument must either be a Sabre_VObject_Element or a string');
+
+        }
+
+    }
+
+
     /* ArrayAccess interface {{{ */
 
     /**
index 9c20e33cea0520b0276ff5dd104483530ffa6489..c38afbfb632b419592fd0c536539b568a6094d83 100644 (file)
@@ -42,16 +42,10 @@ class Sabre_VObject_Reader {
      */
     static function read($data) {
 
-        // Detecting line endings
-        if (strpos($data,"\r\n")!==false) {
-            $newLine = "\r\n";
-        } elseif (strpos($data,"\r")) {
-            $newLine = "\r";
-        } else {
-            $newLine = "\n";
-        }
+        // Normalizing newlines
+        $data = str_replace(array("\r","\n\n"), array("\n","\n"), $data);
 
-        $lines = explode($newLine, $data);
+        $lines = explode("\n", $data);
 
         // Unfolding lines
         $lines2 = array();
index 8c3fe67b1f4eb26f54694d2cca4cb8513837d9c2..950c1c51104d54a82e16b8955424e27efd296204 100644 (file)
@@ -14,7 +14,7 @@ class Sabre_VObject_Version {
     /**
      * Full version number
      */
-    const VERSION = '1.2.0';
+    const VERSION = '1.2.2';
 
     /**
      * Stability : alpha, beta, stable