diff options
Diffstat (limited to '3rdparty/Sabre/CardDAV')
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/CardDAV/AddressBook.php | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/CardDAV/AddressBookQueryParser.php | 18 | ||||
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/CardDAV/AddressBookRoot.php | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/CardDAV/Backend/Abstract.php | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/CardDAV/Backend/PDO.php | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/CardDAV/Card.php | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/CardDAV/IAddressBook.php | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/CardDAV/ICard.php | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/CardDAV/IDirectory.php | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/CardDAV/Plugin.php | 79 | ||||
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/CardDAV/UserAddressBooks.php | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/CardDAV/Version.php | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/CardDAV/includes.php | 0 |
14 files changed, 97 insertions, 6 deletions
diff --git a/3rdparty/Sabre/CardDAV/AddressBook.php b/3rdparty/Sabre/CardDAV/AddressBook.php index 3b381e1eea3..12297175a85 100644..100755 --- a/3rdparty/Sabre/CardDAV/AddressBook.php +++ b/3rdparty/Sabre/CardDAV/AddressBook.php @@ -108,7 +108,9 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca */ public function createFile($name,$vcardData = null) { - $vcardData = stream_get_contents($vcardData); + if (is_resource($vcardData)) { + $vcardData = stream_get_contents($vcardData); + } // Converting to UTF-8, if needed $vcardData = Sabre_DAV_StringUtil::ensureUTF8($vcardData); diff --git a/3rdparty/Sabre/CardDAV/AddressBookQueryParser.php b/3rdparty/Sabre/CardDAV/AddressBookQueryParser.php index 85a4963127b..46bb8ff18dd 100644..100755 --- a/3rdparty/Sabre/CardDAV/AddressBookQueryParser.php +++ b/3rdparty/Sabre/CardDAV/AddressBookQueryParser.php @@ -9,7 +9,7 @@ * @package Sabre * @subpackage CardDAV * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License */ class Sabre_CardDAV_AddressBookQueryParser { @@ -88,12 +88,22 @@ class Sabre_CardDAV_AddressBookQueryParser { if (is_nan($limit)) $limit = null; $filter = $this->xpath->query('/card:addressbook-query/card:filter'); - if ($filter->length !== 1) { + + // According to the CardDAV spec there needs to be exactly 1 filter + // element. However, KDE 4.8.2 contains a bug that will encode 0 filter + // elements, so this is a workaround for that. + // + // See: https://bugs.kde.org/show_bug.cgi?id=300047 + if ($filter->length === 0) { + $test = null; + $filter = null; + } elseif ($filter->length === 1) { + $filter = $filter->item(0); + $test = $this->xpath->evaluate('string(@test)', $filter); + } else { throw new Sabre_DAV_Exception_BadRequest('Only one filter element is allowed'); } - $filter = $filter->item(0); - $test = $this->xpath->evaluate('string(@test)', $filter); if (!$test) $test = self::TEST_ANYOF; if ($test !== self::TEST_ANYOF && $test !== self::TEST_ALLOF) { throw new Sabre_DAV_Exception_BadRequest('The test attribute must either hold "anyof" or "allof"'); diff --git a/3rdparty/Sabre/CardDAV/AddressBookRoot.php b/3rdparty/Sabre/CardDAV/AddressBookRoot.php index 9d37b15f08e..9d37b15f08e 100644..100755 --- a/3rdparty/Sabre/CardDAV/AddressBookRoot.php +++ b/3rdparty/Sabre/CardDAV/AddressBookRoot.php diff --git a/3rdparty/Sabre/CardDAV/Backend/Abstract.php b/3rdparty/Sabre/CardDAV/Backend/Abstract.php index e4806b7161f..e4806b7161f 100644..100755 --- a/3rdparty/Sabre/CardDAV/Backend/Abstract.php +++ b/3rdparty/Sabre/CardDAV/Backend/Abstract.php diff --git a/3rdparty/Sabre/CardDAV/Backend/PDO.php b/3rdparty/Sabre/CardDAV/Backend/PDO.php index 413a77f3bcc..413a77f3bcc 100644..100755 --- a/3rdparty/Sabre/CardDAV/Backend/PDO.php +++ b/3rdparty/Sabre/CardDAV/Backend/PDO.php diff --git a/3rdparty/Sabre/CardDAV/Card.php b/3rdparty/Sabre/CardDAV/Card.php index d7c66333837..d7c66333837 100644..100755 --- a/3rdparty/Sabre/CardDAV/Card.php +++ b/3rdparty/Sabre/CardDAV/Card.php diff --git a/3rdparty/Sabre/CardDAV/IAddressBook.php b/3rdparty/Sabre/CardDAV/IAddressBook.php index 2bc275bcf74..2bc275bcf74 100644..100755 --- a/3rdparty/Sabre/CardDAV/IAddressBook.php +++ b/3rdparty/Sabre/CardDAV/IAddressBook.php diff --git a/3rdparty/Sabre/CardDAV/ICard.php b/3rdparty/Sabre/CardDAV/ICard.php index a17299316c1..a17299316c1 100644..100755 --- a/3rdparty/Sabre/CardDAV/ICard.php +++ b/3rdparty/Sabre/CardDAV/ICard.php diff --git a/3rdparty/Sabre/CardDAV/IDirectory.php b/3rdparty/Sabre/CardDAV/IDirectory.php index 22d4afeb24a..22d4afeb24a 100644..100755 --- a/3rdparty/Sabre/CardDAV/IDirectory.php +++ b/3rdparty/Sabre/CardDAV/IDirectory.php diff --git a/3rdparty/Sabre/CardDAV/Plugin.php b/3rdparty/Sabre/CardDAV/Plugin.php index 9ebec243eb0..ca20e468497 100644..100755 --- a/3rdparty/Sabre/CardDAV/Plugin.php +++ b/3rdparty/Sabre/CardDAV/Plugin.php @@ -52,6 +52,8 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin { $server->subscribeEvent('report', array($this,'report')); $server->subscribeEvent('onHTMLActionsPanel', array($this,'htmlActionsPanel')); $server->subscribeEvent('onBrowserPostAction', array($this,'browserPostAction')); + $server->subscribeEvent('beforeWriteContent', array($this, 'beforeWriteContent')); + $server->subscribeEvent('beforeCreateFile', array($this, 'beforeCreateFile')); /* Namespaces */ $server->xmlNamespaces[self::NS_CARDDAV] = 'card'; @@ -284,6 +286,81 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin { } /** + * This method is triggered before a file gets updated with new content. + * + * This plugin uses this method to ensure that Card nodes receive valid + * vcard data. + * + * @param string $path + * @param Sabre_DAV_IFile $node + * @param resource $data + * @return void + */ + public function beforeWriteContent($path, Sabre_DAV_IFile $node, &$data) { + + if (!$node instanceof Sabre_CardDAV_ICard) + return; + + $this->validateVCard($data); + + } + + /** + * This method is triggered before a new file is created. + * + * This plugin uses this method to ensure that Card nodes receive valid + * vcard data. + * + * @param string $path + * @param resource $data + * @param Sabre_DAV_ICollection $parentNode + * @return void + */ + public function beforeCreateFile($path, &$data, Sabre_DAV_ICollection $parentNode) { + + if (!$parentNode instanceof Sabre_CardDAV_IAddressBook) + return; + + $this->validateVCard($data); + + } + + /** + * Checks if the submitted iCalendar data is in fact, valid. + * + * An exception is thrown if it's not. + * + * @param resource|string $data + * @return void + */ + protected function validateVCard(&$data) { + + // If it's a stream, we convert it to a string first. + if (is_resource($data)) { + $data = stream_get_contents($data); + } + + // Converting the data to unicode, if needed. + $data = Sabre_DAV_StringUtil::ensureUTF8($data); + + try { + + $vobj = Sabre_VObject_Reader::read($data); + + } catch (Sabre_VObject_ParseException $e) { + + throw new Sabre_DAV_Exception_UnsupportedMediaType('This resource only supports valid vcard data. Parse error: ' . $e->getMessage()); + + } + + if ($vobj->name !== 'VCARD') { + throw new Sabre_DAV_Exception_UnsupportedMediaType('This collection can only support vcard objects.'); + } + + } + + + /** * This function handles the addressbook-query REPORT * * This report is used by the client to filter an addressbook based on a @@ -362,6 +439,8 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin { $vcard = Sabre_VObject_Reader::read($vcardData); + if (!$filters) return true; + foreach($filters as $filter) { $isDefined = isset($vcard->{$filter['name']}); diff --git a/3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php b/3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php index 36d9306e7aa..36d9306e7aa 100644..100755 --- a/3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php +++ b/3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php diff --git a/3rdparty/Sabre/CardDAV/UserAddressBooks.php b/3rdparty/Sabre/CardDAV/UserAddressBooks.php index 3f11fb11238..3f11fb11238 100644..100755 --- a/3rdparty/Sabre/CardDAV/UserAddressBooks.php +++ b/3rdparty/Sabre/CardDAV/UserAddressBooks.php diff --git a/3rdparty/Sabre/CardDAV/Version.php b/3rdparty/Sabre/CardDAV/Version.php index 811b929e397..d0623f0d3e8 100644..100755 --- a/3rdparty/Sabre/CardDAV/Version.php +++ b/3rdparty/Sabre/CardDAV/Version.php @@ -16,7 +16,7 @@ class Sabre_CardDAV_Version { /** * Full version number */ - const VERSION = '1.6.1'; + const VERSION = '1.6.3'; /** * Stability : alpha, beta, stable diff --git a/3rdparty/Sabre/CardDAV/includes.php b/3rdparty/Sabre/CardDAV/includes.php index c3b8c04b077..c3b8c04b077 100644..100755 --- a/3rdparty/Sabre/CardDAV/includes.php +++ b/3rdparty/Sabre/CardDAV/includes.php |