From 2086bc4be77ba64337b721cec1cac544c1c58452 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 29 Sep 2011 14:28:57 +0200 Subject: update sabredav to 1.5.3 --- 3rdparty/Sabre/CalDAV/Backend/Abstract.php | 15 ++- 3rdparty/Sabre/CalDAV/Backend/PDO.php | 17 ++- 3rdparty/Sabre/CalDAV/Calendar.php | 4 +- 3rdparty/Sabre/CalDAV/CalendarObject.php | 5 +- 3rdparty/Sabre/CalDAV/ICalendar.php | 18 ++++ 3rdparty/Sabre/CalDAV/ICalendarObject.php | 20 ++++ 3rdparty/Sabre/CalDAV/Plugin.php | 6 +- 3rdparty/Sabre/CalDAV/Version.php | 2 +- 3rdparty/Sabre/CardDAV/AddressBook.php | 2 + 3rdparty/Sabre/CardDAV/Backend/PDO.php | 4 +- 3rdparty/Sabre/CardDAV/Card.php | 3 + 3rdparty/Sabre/CardDAV/Plugin.php | 3 +- .../CardDAV/Property/SupportedAddressData.php | 69 ++++++++++++ 3rdparty/Sabre/CardDAV/Version.php | 4 +- 3rdparty/Sabre/DAV/Browser/Plugin.php | 18 +++- 3rdparty/Sabre/DAV/Server.php | 43 +++++++- 3rdparty/Sabre/DAV/SimpleFile.php | 120 +++++++++++++++++++++ 3rdparty/Sabre/DAV/StringUtil.php | 21 ++++ 3rdparty/Sabre/DAV/URLUtil.php | 42 +++----- 3rdparty/Sabre/DAV/Version.php | 4 +- 3rdparty/Sabre/DAVACL/Principal.php | 13 ++- 3rdparty/Sabre/DAVACL/Version.php | 2 +- 3rdparty/Sabre/HTTP/Response.php | 2 +- 3rdparty/Sabre/HTTP/Version.php | 2 +- 3rdparty/Sabre/VObject/Element/DateTime.php | 6 +- 3rdparty/Sabre/VObject/Element/MultiDateTime.php | 6 +- 3rdparty/Sabre/VObject/Property.php | 38 +++++++ 3rdparty/Sabre/VObject/Reader.php | 12 +-- 3rdparty/Sabre/VObject/Version.php | 2 +- 29 files changed, 414 insertions(+), 89 deletions(-) create mode 100644 3rdparty/Sabre/CalDAV/ICalendar.php create mode 100644 3rdparty/Sabre/CalDAV/ICalendarObject.php create mode 100644 3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php create mode 100644 3rdparty/Sabre/DAV/SimpleFile.php (limited to '3rdparty') diff --git a/3rdparty/Sabre/CalDAV/Backend/Abstract.php b/3rdparty/Sabre/CalDAV/Backend/Abstract.php index 7ac282f44a0..b694eef49e4 100644 --- a/3rdparty/Sabre/CalDAV/Backend/Abstract.php +++ b/3rdparty/Sabre/CalDAV/Backend/Abstract.php @@ -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 diff --git a/3rdparty/Sabre/CalDAV/Backend/PDO.php b/3rdparty/Sabre/CalDAV/Backend/PDO.php index d1785bb8f8f..7b1b33b912e 100644 --- a/3rdparty/Sabre/CalDAV/Backend/PDO.php +++ b/3rdparty/Sabre/CalDAV/Backend/PDO.php @@ -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 diff --git a/3rdparty/Sabre/CalDAV/Calendar.php b/3rdparty/Sabre/CalDAV/Calendar.php index a50aef12b4f..0d2b3875771 100644 --- a/3rdparty/Sabre/CalDAV/Calendar.php +++ b/3rdparty/Sabre/CalDAV/Calendar.php @@ -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) { diff --git a/3rdparty/Sabre/CalDAV/CalendarObject.php b/3rdparty/Sabre/CalDAV/CalendarObject.php index b5c4e49b838..0c99f18deb7 100644 --- a/3rdparty/Sabre/CalDAV/CalendarObject.php +++ b/3rdparty/Sabre/CalDAV/CalendarObject.php @@ -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 index 00000000000..8193dff3a83 --- /dev/null +++ b/3rdparty/Sabre/CalDAV/ICalendar.php @@ -0,0 +1,18 @@ +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. diff --git a/3rdparty/Sabre/CalDAV/Version.php b/3rdparty/Sabre/CalDAV/Version.php index 5ecc0cebb37..df8fe1f6bd6 100644 --- a/3rdparty/Sabre/CalDAV/Version.php +++ b/3rdparty/Sabre/CalDAV/Version.php @@ -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 diff --git a/3rdparty/Sabre/CardDAV/AddressBook.php b/3rdparty/Sabre/CardDAV/AddressBook.php index 04e4c227b86..3333480ea85 100644 --- a/3rdparty/Sabre/CardDAV/AddressBook.php +++ b/3rdparty/Sabre/CardDAV/AddressBook.php @@ -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); diff --git a/3rdparty/Sabre/CardDAV/Backend/PDO.php b/3rdparty/Sabre/CardDAV/Backend/PDO.php index 63a74745aac..5556d0a7648 100644 --- a/3rdparty/Sabre/CardDAV/Backend/PDO.php +++ b/3rdparty/Sabre/CardDAV/Backend/PDO.php @@ -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(), ); } diff --git a/3rdparty/Sabre/CardDAV/Card.php b/3rdparty/Sabre/CardDAV/Card.php index 52d8b79d7dd..5298d31e245 100644 --- a/3rdparty/Sabre/CardDAV/Card.php +++ b/3rdparty/Sabre/CardDAV/Card.php @@ -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; diff --git a/3rdparty/Sabre/CardDAV/Plugin.php b/3rdparty/Sabre/CardDAV/Plugin.php index a96f9aaebb6..17766b78278 100644 --- a/3rdparty/Sabre/CardDAV/Plugin.php +++ b/3rdparty/Sabre/CardDAV/Plugin.php @@ -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 index 00000000000..d57d3a6e7bd --- /dev/null +++ b/3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php @@ -0,0 +1,69 @@ + '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); + + } + + } + +} diff --git a/3rdparty/Sabre/CardDAV/Version.php b/3rdparty/Sabre/CardDAV/Version.php index 8961027fc89..c76ee360354 100644 --- a/3rdparty/Sabre/CardDAV/Version.php +++ b/3rdparty/Sabre/CardDAV/Version.php @@ -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'; } diff --git a/3rdparty/Sabre/DAV/Browser/Plugin.php b/3rdparty/Sabre/DAV/Browser/Plugin.php index 8e0ca24cff2..cd5617babb1 100644 --- a/3rdparty/Sabre/DAV/Browser/Plugin.php +++ b/3rdparty/Sabre/DAV/Browser/Plugin.php @@ -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.= "
"; - if ($this->enablePost) { + if ($this->enablePost && $parent instanceof Sabre_DAV_ICollection) { $html.= '

Create new folder

diff --git a/3rdparty/Sabre/DAV/Server.php b/3rdparty/Sabre/DAV/Server.php index c6c63143d13..b99866dad5e 100644 --- a/3rdparty/Sabre/DAV/Server.php +++ b/3rdparty/Sabre/DAV/Server.php @@ -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 index 00000000000..304dff1c5ec --- /dev/null +++ b/3rdparty/Sabre/DAV/SimpleFile.php @@ -0,0 +1,120 @@ +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; + + } + +} + +?> diff --git a/3rdparty/Sabre/DAV/StringUtil.php b/3rdparty/Sabre/DAV/StringUtil.php index b0b708f8e0f..440cf6866ca 100644 --- a/3rdparty/Sabre/DAV/StringUtil.php +++ b/3rdparty/Sabre/DAV/StringUtil.php @@ -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; + } } diff --git a/3rdparty/Sabre/DAV/URLUtil.php b/3rdparty/Sabre/DAV/URLUtil.php index 1502e4dd2ce..8f38749264b 100644 --- a/3rdparty/Sabre/DAV/URLUtil.php +++ b/3rdparty/Sabre/DAV/URLUtil.php @@ -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=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; diff --git a/3rdparty/Sabre/DAV/Version.php b/3rdparty/Sabre/DAV/Version.php index c93d793ab67..e7f7f83e6ff 100644 --- a/3rdparty/Sabre/DAV/Version.php +++ b/3rdparty/Sabre/DAV/Version.php @@ -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'; } diff --git a/3rdparty/Sabre/DAVACL/Principal.php b/3rdparty/Sabre/DAVACL/Principal.php index 158b271058c..790603c900f 100644 --- a/3rdparty/Sabre/DAVACL/Principal.php +++ b/3rdparty/Sabre/DAVACL/Principal.php @@ -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); + } /** diff --git a/3rdparty/Sabre/DAVACL/Version.php b/3rdparty/Sabre/DAVACL/Version.php index a705507486c..124463e311e 100644 --- a/3rdparty/Sabre/DAVACL/Version.php +++ b/3rdparty/Sabre/DAVACL/Version.php @@ -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 diff --git a/3rdparty/Sabre/HTTP/Response.php b/3rdparty/Sabre/HTTP/Response.php index c8c77251a17..dce6feac553 100644 --- a/3rdparty/Sabre/HTTP/Response.php +++ b/3rdparty/Sabre/HTTP/Response.php @@ -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', diff --git a/3rdparty/Sabre/HTTP/Version.php b/3rdparty/Sabre/HTTP/Version.php index f8d1bb75429..67be232fc26 100644 --- a/3rdparty/Sabre/HTTP/Version.php +++ b/3rdparty/Sabre/HTTP/Version.php @@ -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 diff --git a/3rdparty/Sabre/VObject/Element/DateTime.php b/3rdparty/Sabre/VObject/Element/DateTime.php index 30e5c6ca86a..63af858dd68 100644 --- a/3rdparty/Sabre/VObject/Element/DateTime.php +++ b/3rdparty/Sabre/VObject/Element/DateTime.php @@ -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 : diff --git a/3rdparty/Sabre/VObject/Element/MultiDateTime.php b/3rdparty/Sabre/VObject/Element/MultiDateTime.php index 5e677f5e5b5..07f7e82c346 100644 --- a/3rdparty/Sabre/VObject/Element/MultiDateTime.php +++ b/3rdparty/Sabre/VObject/Element/MultiDateTime.php @@ -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 : diff --git a/3rdparty/Sabre/VObject/Property.php b/3rdparty/Sabre/VObject/Property.php index 201e6356ad6..624dd4b8a58 100644 --- a/3rdparty/Sabre/VObject/Property.php +++ b/3rdparty/Sabre/VObject/Property.php @@ -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 {{{ */ /** diff --git a/3rdparty/Sabre/VObject/Reader.php b/3rdparty/Sabre/VObject/Reader.php index 9c20e33cea0..c38afbfb632 100644 --- a/3rdparty/Sabre/VObject/Reader.php +++ b/3rdparty/Sabre/VObject/Reader.php @@ -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(); diff --git a/3rdparty/Sabre/VObject/Version.php b/3rdparty/Sabre/VObject/Version.php index 8c3fe67b1f4..950c1c51104 100644 --- a/3rdparty/Sabre/VObject/Version.php +++ b/3rdparty/Sabre/VObject/Version.php @@ -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 -- cgit v1.2.3