[Pkg-owncloud-commits] [php-sabredav] 163/275: Support for max-resource-size.
David Prévot
taffit at moszumanska.debian.org
Thu Sep 25 14:56:04 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit 3f1a7215e9c150a558d61095f35f1b8ff3c79a3a
Author: Evert Pot <me at evertpot.com>
Date: Tue Aug 19 10:53:09 2014 -0400
Support for max-resource-size.
Also moved supported-collation-set and supported-calendar-data to the
plugin.
---
ChangeLog.md | 5 +++++
lib/CalDAV/Calendar.php | 18 ++++--------------
lib/CalDAV/Plugin.php | 21 +++++++++++++++++++++
tests/Sabre/CalDAV/CalendarTest.php | 8 --------
4 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index 823aee2..63c9781 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -37,6 +37,11 @@ ChangeLog
instead of 501, as per RFC7231.
* Added: Browser plugin can now display the contents of the
`{DAV:}supported-privilege-set` property.
+* Added: Now reporting `CALDAV:max-resource-size`, but we're not actively
+ restricting it yet.
+* Changed: CalDAV plugin is now responsible for reporting
+ `CALDAV:supported-collation-set` and `CALDAV:supported-calendar-data`
+ properties.
2.0.4 (????-??-??)
------------------
diff --git a/lib/CalDAV/Calendar.php b/lib/CalDAV/Calendar.php
index 135bb90..18cf911 100644
--- a/lib/CalDAV/Calendar.php
+++ b/lib/CalDAV/Calendar.php
@@ -85,20 +85,10 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection,
$response = [];
- foreach($requestedProperties as $prop) switch($prop) {
-
- case '{urn:ietf:params:xml:ns:caldav}supported-calendar-data' :
- $response[$prop] = new Property\SupportedCalendarData();
- break;
- case '{urn:ietf:params:xml:ns:caldav}supported-collation-set' :
- $response[$prop] = new Property\SupportedCollationSet();
- break;
- case '{DAV:}owner' :
- $response[$prop] = new DAVACL\Property\Principal(DAVACL\Property\Principal::HREF,$this->calendarInfo['principaluri']);
- break;
- default :
- if (isset($this->calendarInfo[$prop])) $response[$prop] = $this->calendarInfo[$prop];
- break;
+ foreach($requestedProperties as $prop) {
+
+ if (isset($this->calendarInfo[$prop]))
+ $response[$prop] = $this->calendarInfo[$prop];
}
return $response;
diff --git a/lib/CalDAV/Plugin.php b/lib/CalDAV/Plugin.php
index 8461ea4..5bb1790 100644
--- a/lib/CalDAV/Plugin.php
+++ b/lib/CalDAV/Plugin.php
@@ -48,6 +48,13 @@ class Plugin extends DAV\ServerPlugin {
protected $server;
/**
+ * The default PDO storage uses a MySQL MEDIUMBLOB for iCalendar data,
+ * which can hold up to 2^24 = 16777216 bytes. This is plenty. We're
+ * capping it to 10M here.
+ */
+ protected $maxResourceSize = 10000000;
+
+ /**
* Use this method to tell the server this plugin defines additional
* HTTP methods.
*
@@ -303,6 +310,20 @@ class Plugin extends DAV\ServerPlugin {
*/
public function propFind(DAV\PropFind $propFind, DAV\INode $node) {
+ $ns = '{' . self::NS_CALDAV . '}';
+
+ if ($node instanceof ICalendarContainer) {
+
+ $propFind->handle($ns . 'max-resource-size', $this->maxResourceSize);
+ $propFind->handle($ns . 'supported-calendar-data', function() {
+ return new Property\SupportedCalendarData();
+ });
+ $propFind->handle($ns . 'supported-collation-set', function() {
+ return new Property\SupportedCollationSet();
+ });
+
+ }
+
if ($node instanceof DAVACL\IPrincipal) {
$principalUrl = $node->getPrincipalUrl();
diff --git a/tests/Sabre/CalDAV/CalendarTest.php b/tests/Sabre/CalDAV/CalendarTest.php
index a5f3e3d..950f081 100644
--- a/tests/Sabre/CalDAV/CalendarTest.php
+++ b/tests/Sabre/CalDAV/CalendarTest.php
@@ -74,9 +74,6 @@ class CalendarTest extends \PHPUnit_Framework_TestCase {
$question = array(
'{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set',
- '{urn:ietf:params:xml:ns:caldav}supported-calendar-data',
- '{urn:ietf:params:xml:ns:caldav}supported-collation-set',
- '{DAV:}owner',
);
$result = $this->calendar->getProperties($question);
@@ -85,11 +82,6 @@ class CalendarTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals(array('VEVENT','VTODO'), $result['{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set']->getValue());
- $this->assertTrue($result['{urn:ietf:params:xml:ns:caldav}supported-collation-set'] instanceof Property\SupportedCollationSet);
-
- $this->assertTrue($result['{DAV:}owner'] instanceof DAVACL\Property\Principal);
- $this->assertEquals('principals/user1', $result['{DAV:}owner']->getHref());
-
}
/**
--
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