[Pkg-owncloud-commits] [php-sabredav] 05/10: Throwing an exception when running into empty supported-calendar-component-set.
David Prévot
taffit at moszumanska.debian.org
Sat Sep 5 15:24:03 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to tag 3.0.4
in repository php-sabredav.
commit 704ae129ab1621760b4b6ff36472a922c389ee82
Author: Evert Pot <me at evertpot.com>
Date: Fri Aug 28 22:48:37 2015 +0200
Throwing an exception when running into empty supported-calendar-component-set.
Fixes #709.
---
CHANGELOG.md | 2 ++
lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php | 7 ++++++-
.../CalDAV/Xml/Property/SupportedCalendarComponentSetTest.php | 3 +++
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 06df25a..2b85c0e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@ ChangeLog
------------------
* #703: PropPatch in client is not correctly encoded.
+* #709: Throw exception when running into empty
+ `supported-calendar-component-set.
3.0.3 (2015-08-06)
diff --git a/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php b/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php
index 58c4c3d..7c6821f 100644
--- a/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php
+++ b/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php
@@ -3,6 +3,7 @@
namespace Sabre\CalDAV\Xml\Property;
use Sabre\Xml\Element;
+use Sabre\Xml\ParseException;
use Sabre\Xml\Reader;
use Sabre\Xml\Writer;
use Sabre\CalDAV\Plugin;
@@ -111,12 +112,16 @@ class SupportedCalendarComponentSet implements Element {
$components = [];
- foreach ($elems as $elem) {
+ foreach ((array)$elems as $elem) {
if ($elem['name'] === '{' . Plugin::NS_CALDAV . '}comp') {
$components[] = $elem['attributes']['name'];
}
}
+ if (!$components) {
+ throw new ParseException('supported-calendar-component-set must have at least one CALDAV:comp element');
+ }
+
return new self($components);
}
diff --git a/tests/Sabre/CalDAV/Xml/Property/SupportedCalendarComponentSetTest.php b/tests/Sabre/CalDAV/Xml/Property/SupportedCalendarComponentSetTest.php
index 0785e7c..44a7b88 100644
--- a/tests/Sabre/CalDAV/Xml/Property/SupportedCalendarComponentSetTest.php
+++ b/tests/Sabre/CalDAV/Xml/Property/SupportedCalendarComponentSetTest.php
@@ -78,6 +78,9 @@ XML;
}
+ /**
+ * @expectedException \Sabre\Xml\ParseException
+ */
function testUnserializeEmpty() {
$cal = CalDAV\Plugin::NS_CALDAV;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list