Skip to content

Commit fa466a0

Browse files
Merge pull request #33139 from nextcloud/fix/check-calendar-uri-length
Check calendar URI length before creation
2 parents aa150b9 + d41841b commit fa466a0

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

apps/dav/lib/CalDAV/CalDavBackend.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
use OCA\DAV\Events\SubscriptionCreatedEvent;
6565
use OCA\DAV\Events\SubscriptionDeletedEvent;
6666
use OCA\DAV\Events\SubscriptionUpdatedEvent;
67+
use OCP\Calendar\Exceptions\CalendarException;
6768
use OCP\DB\Exception;
6869
use OCP\DB\QueryBuilder\IQueryBuilder;
6970
use OCP\EventDispatcher\IEventDispatcher;
@@ -770,8 +771,14 @@ public function getSubscriptionById($subscriptionId) {
770771
* @param string $calendarUri
771772
* @param array $properties
772773
* @return int
774+
*
775+
* @throws CalendarException
773776
*/
774777
public function createCalendar($principalUri, $calendarUri, array $properties) {
778+
if (strlen($calendarUri) > 255) {
779+
throw new CalendarException('URI too long. Calendar not created');
780+
}
781+
775782
$values = [
776783
'principaluri' => $this->convertPrincipal($principalUri, true),
777784
'uri' => $calendarUri,

apps/dav/lib/CardDAV/CardDavBackend.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatc
389389
* @throws BadRequest
390390
*/
391391
public function createAddressBook($principalUri, $url, array $properties) {
392+
if (strlen($url) > 255) {
393+
throw new BadRequest('URI too long. Address book not created');
394+
}
395+
392396
$values = [
393397
'displayname' => null,
394398
'description' => null,

0 commit comments

Comments
 (0)