[Pkg-owncloud-commits] [php-sabredav] 124/220: Support for Prefer: handling=strict header
David Prévot
taffit at moszumanska.debian.org
Thu May 12 01:21:16 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit 314c36ae098f8bf4895168d7ad2dce167424e055
Author: Evert Pot <me at evertpot.com>
Date: Thu Mar 31 22:02:52 2016 -0400
Support for Prefer: handling=strict header
---
lib/CardDAV/Plugin.php | 11 +++++++---
tests/Sabre/CardDAV/ValidateVCardTest.php | 34 +++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/lib/CardDAV/Plugin.php b/lib/CardDAV/Plugin.php
index 9f1524d..bd7f881 100644
--- a/lib/CardDAV/Plugin.php
+++ b/lib/CardDAV/Plugin.php
@@ -361,9 +361,14 @@ class Plugin extends DAV\ServerPlugin {
throw new DAV\Exception\UnsupportedMediaType('This collection can only support vcard objects.');
}
- $messages = $vobj->validate(
- VObject\Node::PROFILE_CARDDAV | VObject\Node::REPAIR
- );
+ $options = VObject\Node::PROFILE_CARDDAV;
+ $prefer = $this->server->getHTTPPrefer();
+
+ if ($prefer['handling'] !== 'strict') {
+ $options |= VObject\Node::REPAIR;
+ }
+
+ $messages = $vobj->validate($options);
$highestLevel = 0;
$warningMessage = null;
diff --git a/tests/Sabre/CardDAV/ValidateVCardTest.php b/tests/Sabre/CardDAV/ValidateVCardTest.php
index 84d523d..756e440 100644
--- a/tests/Sabre/CardDAV/ValidateVCardTest.php
+++ b/tests/Sabre/CardDAV/ValidateVCardTest.php
@@ -178,6 +178,40 @@ VCF;
}
+ /**
+ * This test creates an intentionally broken vCard that vobject is able
+ * to automatically repair.
+ *
+ * However, we're supplying a heading asking the server to treat the
+ * request as strict, so the server should still let the request fail.
+ *
+ * @depends testCreateFileValid
+ */
+ function testCreateVCardStrictFail() {
+
+ $request = new HTTP\Request(
+ 'PUT',
+ '/addressbooks/admin/addressbook1/blabla.vcf',
+ [
+ 'Prefer' => 'handling=strict',
+ ]
+ );
+
+ // The error in this vcard is that there's not enough semi-colons in N
+ $vcard = <<<VCF
+BEGIN:VCARD
+VERSION:4.0
+UID:foo
+FN:Firstname LastName
+N:LastName;FirstName;;
+END:VCARD
+VCF;
+
+ $request->setBody($vcard);
+ $this->request($request, 415);
+
+ }
+
function testCreateFileNoUID() {
$request = new HTTP\Request(
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-php/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list