Skip to content

Commit

Permalink
Merge pull request #40081 from nextcloud/fix/stable27/check-vobject-e…
Browse files Browse the repository at this point in the history
…xists

[stable27] fix(CalDAV): check voject exists before attempting any operation
  • Loading branch information
AndyScherzinger committed Aug 29, 2023
2 parents a480365 + c3f92ac commit 67ff5d5
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions lib/private/Calendar/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,26 @@ public function newQuery(string $principalUri): ICalendarQuery {
/**
* @throws \OCP\DB\Exception
*/
public function handleIMipReply(string $principalUri, string $sender, string $recipient, string $calendarData): bool {
/** @var VCalendar $vObject */
public function handleIMipReply(
string $principalUri,
string $sender,
string $recipient,
string $calendarData,
): bool {
/** @var VCalendar $vObject|null */
$vObject = Reader::read($calendarData);
/** @var VEvent $vEvent */

if ($vObject === null) {
return false;
}

/** @var VEvent|null $vEvent */
$vEvent = $vObject->{'VEVENT'};

if ($vEvent === null) {
return false;
}

// First, we check if the correct method is passed to us
if (strcasecmp('REPLY', $vObject->{'METHOD'}->getValue()) !== 0) {
$this->logger->warning('Wrong method provided for processing');
Expand Down Expand Up @@ -309,11 +323,27 @@ public function handleIMipReply(string $principalUri, string $sender, string $re
* @since 25.0.0
* @throws \OCP\DB\Exception
*/
public function handleIMipCancel(string $principalUri, string $sender, ?string $replyTo, string $recipient, string $calendarData): bool {
public function handleIMipCancel(
string $principalUri,
string $sender,
?string $replyTo,
string $recipient,
string $calendarData,
): bool {
/** @var VCalendar $vObject|null */
$vObject = Reader::read($calendarData);
/** @var VEvent $vEvent */

if ($vObject === null) {
return false;
}

/** @var VEvent|null $vEvent */
$vEvent = $vObject->{'VEVENT'};

if ($vEvent === null) {
return false;
}

// First, we check if the correct method is passed to us
if (strcasecmp('CANCEL', $vObject->{'METHOD'}->getValue()) !== 0) {
$this->logger->warning('Wrong method provided for processing');
Expand Down

0 comments on commit 67ff5d5

Please sign in to comment.