Skip to content

Commit

Permalink
Merge pull request #33784 from nextcloud/backport/33139/stable23
Browse files Browse the repository at this point in the history
[stable23] Check calendar URI length before creation
  • Loading branch information
blizzz authored Sep 27, 2022
2 parents 84236c2 + 992e05e commit 067f62c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
use OCA\DAV\Events\SubscriptionCreatedEvent;
use OCA\DAV\Events\SubscriptionDeletedEvent;
use OCA\DAV\Events\SubscriptionUpdatedEvent;
use OCP\Calendar\Exceptions\CalendarException;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
Expand Down Expand Up @@ -793,8 +794,14 @@ public function getSubscriptionById($subscriptionId) {
* @param string $calendarUri
* @param array $properties
* @return int
*
* @throws CalendarException
*/
public function createCalendar($principalUri, $calendarUri, array $properties) {
if (strlen($calendarUri) > 255) {
throw new CalendarException('URI too long. Calendar not created');
}

$values = [
'principaluri' => $this->convertPrincipal($principalUri, true),
'uri' => $calendarUri,
Expand Down
4 changes: 4 additions & 0 deletions apps/dav/lib/CardDAV/CardDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatc
* @throws BadRequest
*/
public function createAddressBook($principalUri, $url, array $properties) {
if (strlen($url) > 255) {
throw new BadRequest('URI too long. Address book not created');
}

$values = [
'displayname' => null,
'description' => null,
Expand Down

0 comments on commit 067f62c

Please sign in to comment.