Skip to content

Commit

Permalink
Merge pull request #33139 from nextcloud/fix/check-calendar-uri-length
Browse files Browse the repository at this point in the history
Check calendar URI length before creation
  • Loading branch information
nickvergessen authored Aug 26, 2022
2 parents aa150b9 + d41841b commit fa466a0
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 @@ -64,6 +64,7 @@
use OCA\DAV\Events\SubscriptionCreatedEvent;
use OCA\DAV\Events\SubscriptionDeletedEvent;
use OCA\DAV\Events\SubscriptionUpdatedEvent;
use OCP\Calendar\Exceptions\CalendarException;
use OCP\DB\Exception;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\IEventDispatcher;
Expand Down Expand Up @@ -770,8 +771,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 @@ -389,6 +389,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 fa466a0

Please sign in to comment.