summaryrefslogtreecommitdiffstats
path: root/3rdparty/Sabre/CardDAV
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-10-27 16:33:10 +0200
committerBart Visscher <bartv@thisnet.nl>2012-10-27 16:33:10 +0200
commit894d44e796bf99882383fcee42f754c5d9d6828b (patch)
tree848094d3e67f86a337b9be332108fe571334303c /3rdparty/Sabre/CardDAV
parentc1c76539cc2878c058de15892dd05d6dd8b4b9a5 (diff)
parentb2b84f3a6f3c98005f80c6c7c558a33b4ea36193 (diff)
downloadnextcloud-server-894d44e796bf99882383fcee42f754c5d9d6828b.tar.gz
nextcloud-server-894d44e796bf99882383fcee42f754c5d9d6828b.zip
Merge remote-tracking branch 'git://github.com/susinths/SabreDAV_1.7.1.git'
Conflicts: lib/base.php
Diffstat (limited to '3rdparty/Sabre/CardDAV')
-rw-r--r--[-rwxr-xr-x]3rdparty/Sabre/CardDAV/AddressBook.php4
-rw-r--r--[-rwxr-xr-x]3rdparty/Sabre/CardDAV/AddressBookQueryParser.php0
-rw-r--r--[-rwxr-xr-x]3rdparty/Sabre/CardDAV/AddressBookRoot.php0
-rw-r--r--[-rwxr-xr-x]3rdparty/Sabre/CardDAV/Backend/Abstract.php0
-rw-r--r--[-rwxr-xr-x]3rdparty/Sabre/CardDAV/Backend/PDO.php0
-rw-r--r--[-rwxr-xr-x]3rdparty/Sabre/CardDAV/Card.php16
-rw-r--r--[-rwxr-xr-x]3rdparty/Sabre/CardDAV/IAddressBook.php0
-rw-r--r--[-rwxr-xr-x]3rdparty/Sabre/CardDAV/ICard.php0
-rw-r--r--[-rwxr-xr-x]3rdparty/Sabre/CardDAV/IDirectory.php0
-rw-r--r--[-rwxr-xr-x]3rdparty/Sabre/CardDAV/Plugin.php55
-rw-r--r--[-rwxr-xr-x]3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php0
-rw-r--r--[-rwxr-xr-x]3rdparty/Sabre/CardDAV/UserAddressBooks.php0
-rw-r--r--3rdparty/Sabre/CardDAV/VCFExportPlugin.php107
-rw-r--r--[-rwxr-xr-x]3rdparty/Sabre/CardDAV/Version.php2
-rw-r--r--[-rwxr-xr-x]3rdparty/Sabre/CardDAV/includes.php1
15 files changed, 166 insertions, 19 deletions
diff --git a/3rdparty/Sabre/CardDAV/AddressBook.php b/3rdparty/Sabre/CardDAV/AddressBook.php
index 12297175a85..8d545114d97 100755..100644
--- a/3rdparty/Sabre/CardDAV/AddressBook.php
+++ b/3rdparty/Sabre/CardDAV/AddressBook.php
@@ -55,7 +55,7 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
* Returns a card
*
* @param string $name
- * @return Sabre_DAV_Card
+ * @return Sabre_CardDAV_ICard
*/
public function getChild($name) {
@@ -104,7 +104,7 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
*
* @param string $name
* @param resource $vcardData
- * @return void|null
+ * @return string|null
*/
public function createFile($name,$vcardData = null) {
diff --git a/3rdparty/Sabre/CardDAV/AddressBookQueryParser.php b/3rdparty/Sabre/CardDAV/AddressBookQueryParser.php
index 46bb8ff18dd..46bb8ff18dd 100755..100644
--- a/3rdparty/Sabre/CardDAV/AddressBookQueryParser.php
+++ b/3rdparty/Sabre/CardDAV/AddressBookQueryParser.php
diff --git a/3rdparty/Sabre/CardDAV/AddressBookRoot.php b/3rdparty/Sabre/CardDAV/AddressBookRoot.php
index 9d37b15f08e..9d37b15f08e 100755..100644
--- 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 100755..100644
--- 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 100755..100644
--- 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..0e35d321eb8 100755..100644
--- a/3rdparty/Sabre/CardDAV/Card.php
+++ b/3rdparty/Sabre/CardDAV/Card.php
@@ -6,7 +6,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_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard, Sabre_DAVACL_IACL {
@@ -78,7 +78,7 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
* Updates the VCard-formatted object
*
* @param string $cardData
- * @return void
+ * @return string|null
*/
public function put($cardData) {
@@ -114,7 +114,7 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
*/
public function getContentType() {
- return 'text/x-vcard';
+ return 'text/x-vcard; charset=utf-8';
}
@@ -128,7 +128,13 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
if (isset($this->cardData['etag'])) {
return $this->cardData['etag'];
} else {
- return '"' . md5($this->get()) . '"';
+ $data = $this->get();
+ if (is_string($data)) {
+ return '"' . md5($data) . '"';
+ } else {
+ // We refuse to calculate the md5 if it's a stream.
+ return null;
+ }
}
}
@@ -136,7 +142,7 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
/**
* Returns the last modification date as a unix timestamp
*
- * @return time
+ * @return int
*/
public function getLastModified() {
diff --git a/3rdparty/Sabre/CardDAV/IAddressBook.php b/3rdparty/Sabre/CardDAV/IAddressBook.php
index 2bc275bcf74..2bc275bcf74 100755..100644
--- 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 100755..100644
--- 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 100755..100644
--- 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 96def6dd96b..12bccaec4fb 100755..100644
--- a/3rdparty/Sabre/CardDAV/Plugin.php
+++ b/3rdparty/Sabre/CardDAV/Plugin.php
@@ -1,5 +1,7 @@
<?php
+use Sabre\VObject;
+
/**
* CardDAV plugin
*
@@ -48,6 +50,7 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
/* Events */
$server->subscribeEvent('beforeGetProperties', array($this, 'beforeGetProperties'));
+ $server->subscribeEvent('afterGetProperties', array($this, 'afterGetProperties'));
$server->subscribeEvent('updateProperties', array($this, 'updateProperties'));
$server->subscribeEvent('report', array($this,'report'));
$server->subscribeEvent('onHTMLActionsPanel', array($this,'htmlActionsPanel'));
@@ -153,10 +156,6 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
if (is_resource($val))
$val = stream_get_contents($val);
- // Taking out \r to not screw up the xml output
- //$returnedProperties[200][$addressDataProp] = str_replace("\r","", $val);
- // The stripping of \r breaks the Mail App in OSX Mountain Lion
- // this is fixed in master, but not backported. /Tanghus
$returnedProperties[200][$addressDataProp] = $val;
}
@@ -190,7 +189,7 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
* @param array $mutations
* @param array $result
* @param Sabre_DAV_INode $node
- * @return void
+ * @return bool
*/
public function updateProperties(&$mutations, &$result, $node) {
@@ -272,7 +271,7 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
$properties = array_keys(Sabre_DAV_XMLUtil::parseProperties($dom->firstChild));
- $hrefElems = $dom->getElementsByTagNameNS('urn:DAV','href');
+ $hrefElems = $dom->getElementsByTagNameNS('DAV:','href');
$propertyList = array();
foreach($hrefElems as $elem) {
@@ -282,9 +281,12 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
}
+ $prefer = $this->server->getHTTPPRefer();
+
$this->server->httpResponse->sendStatus(207);
$this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8');
- $this->server->httpResponse->sendBody($this->server->generateMultiStatus($propertyList));
+ $this->server->httpResponse->setHeader('Vary','Brief,Prefer');
+ $this->server->httpResponse->sendBody($this->server->generateMultiStatus($propertyList, $prefer['return-minimal']));
}
@@ -348,9 +350,9 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
try {
- $vobj = Sabre_VObject_Reader::read($data);
+ $vobj = VObject\Reader::read($data);
- } catch (Sabre_VObject_ParseException $e) {
+ } catch (VObject\ParseException $e) {
throw new Sabre_DAV_Exception_UnsupportedMediaType('This resource only supports valid vcard data. Parse error: ' . $e->getMessage());
@@ -360,6 +362,10 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
throw new Sabre_DAV_Exception_UnsupportedMediaType('This collection can only support vcard objects.');
}
+ if (!isset($vobj->UID)) {
+ throw new Sabre_DAV_Exception_BadRequest('Every vcard must have an UID.');
+ }
+
}
@@ -424,9 +430,12 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
}
+ $prefer = $this->server->getHTTPPRefer();
+
$this->server->httpResponse->sendStatus(207);
$this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8');
- $this->server->httpResponse->sendBody($this->server->generateMultiStatus($result));
+ $this->server->httpResponse->setHeader('Vary','Brief,Prefer');
+ $this->server->httpResponse->sendBody($this->server->generateMultiStatus($result, $prefer['return-minimal']));
}
@@ -440,7 +449,7 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
*/
public function validateFilters($vcardData, array $filters, $test) {
- $vcard = Sabre_VObject_Reader::read($vcardData);
+ $vcard = VObject\Reader::read($vcardData);
if (!$filters) return true;
@@ -616,6 +625,30 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
}
/**
+ * This event is triggered after webdav-properties have been retrieved.
+ *
+ * @return bool
+ */
+ public function afterGetProperties($uri, &$properties) {
+
+ // If the request was made using the SOGO connector, we must rewrite
+ // the content-type property. By default SabreDAV will send back
+ // text/x-vcard; charset=utf-8, but for SOGO we must strip that last
+ // part.
+ if (!isset($properties[200]['{DAV:}getcontenttype']))
+ return;
+
+ if (strpos($this->server->httpRequest->getHeader('User-Agent'),'Thunderbird')===false) {
+ return;
+ }
+
+ if (strpos($properties[200]['{DAV:}getcontenttype'],'text/x-vcard')===0) {
+ $properties[200]['{DAV:}getcontenttype'] = 'text/x-vcard';
+ }
+
+ }
+
+ /**
* This method is used to generate HTML output for the
* Sabre_DAV_Browser_Plugin. This allows us to generate an interface users
* can use to create new calendars.
diff --git a/3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php b/3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php
index 36d9306e7aa..36d9306e7aa 100755..100644
--- 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 100755..100644
--- a/3rdparty/Sabre/CardDAV/UserAddressBooks.php
+++ b/3rdparty/Sabre/CardDAV/UserAddressBooks.php
diff --git a/3rdparty/Sabre/CardDAV/VCFExportPlugin.php b/3rdparty/Sabre/CardDAV/VCFExportPlugin.php
new file mode 100644
index 00000000000..8850fef8afb
--- /dev/null
+++ b/3rdparty/Sabre/CardDAV/VCFExportPlugin.php
@@ -0,0 +1,107 @@
+<?php
+
+use Sabre\VObject;
+
+/**
+ * VCF Exporter
+ *
+ * This plugin adds the ability to export entire address books as .vcf files.
+ * This is useful for clients that don't support CardDAV yet. They often do
+ * support vcf files.
+ *
+ * @package Sabre
+ * @subpackage CardDAV
+ * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
+ * @author Evert Pot (http://www.rooftopsolutions.nl/)
+ * @author Thomas Tanghus (http://tanghus.net/)
+ * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
+ */
+class Sabre_CardDAV_VCFExportPlugin extends Sabre_DAV_ServerPlugin {
+
+ /**
+ * Reference to Server class
+ *
+ * @var Sabre_DAV_Server
+ */
+ private $server;
+
+ /**
+ * Initializes the plugin and registers event handlers
+ *
+ * @param Sabre_DAV_Server $server
+ * @return void
+ */
+ public function initialize(Sabre_DAV_Server $server) {
+
+ $this->server = $server;
+ $this->server->subscribeEvent('beforeMethod',array($this,'beforeMethod'), 90);
+
+ }
+
+ /**
+ * 'beforeMethod' event handles. This event handles intercepts GET requests ending
+ * with ?export
+ *
+ * @param string $method
+ * @param string $uri
+ * @return bool
+ */
+ public function beforeMethod($method, $uri) {
+
+ if ($method!='GET') return;
+ if ($this->server->httpRequest->getQueryString()!='export') return;
+
+ // splitting uri
+ list($uri) = explode('?',$uri,2);
+
+ $node = $this->server->tree->getNodeForPath($uri);
+
+ if (!($node instanceof Sabre_CardDAV_IAddressBook)) return;
+
+ // Checking ACL, if available.
+ if ($aclPlugin = $this->server->getPlugin('acl')) {
+ $aclPlugin->checkPrivileges($uri, '{DAV:}read');
+ }
+
+ $this->server->httpResponse->setHeader('Content-Type','text/directory');
+ $this->server->httpResponse->sendStatus(200);
+
+ $nodes = $this->server->getPropertiesForPath($uri, array(
+ '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}address-data',
+ ),1);
+
+ $this->server->httpResponse->sendBody($this->generateVCF($nodes));
+
+ // Returning false to break the event chain
+ return false;
+
+ }
+
+ /**
+ * Merges all vcard objects, and builds one big vcf export
+ *
+ * @param array $nodes
+ * @return string
+ */
+ public function generateVCF(array $nodes) {
+
+ $output = "";
+
+ foreach($nodes as $node) {
+
+ if (!isset($node[200]['{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}address-data'])) {
+ continue;
+ }
+ $nodeData = $node[200]['{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}address-data'];
+
+ // Parsing this node so VObject can clean up the output.
+ $output .=
+ VObject\Reader::read($nodeData)->serialize();
+
+ }
+
+ return $output;
+
+ }
+
+}
diff --git a/3rdparty/Sabre/CardDAV/Version.php b/3rdparty/Sabre/CardDAV/Version.php
index d0623f0d3e8..6b70a2df9b5 100755..100644
--- 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.3';
+ const VERSION = '1.7.0';
/**
* Stability : alpha, beta, stable
diff --git a/3rdparty/Sabre/CardDAV/includes.php b/3rdparty/Sabre/CardDAV/includes.php
index c3b8c04b077..08b4f76bd01 100755..100644
--- a/3rdparty/Sabre/CardDAV/includes.php
+++ b/3rdparty/Sabre/CardDAV/includes.php
@@ -26,6 +26,7 @@ include __DIR__ . '/IDirectory.php';
include __DIR__ . '/Plugin.php';
include __DIR__ . '/Property/SupportedAddressData.php';
include __DIR__ . '/UserAddressBooks.php';
+include __DIR__ . '/VCFExportPlugin.php';
include __DIR__ . '/Version.php';
include __DIR__ . '/AddressBook.php';
include __DIR__ . '/Card.php';