Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(caldav): Ignore invalid events for reminder generation #38301

Merged
merged 2 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/dav/lib/CalDAV/Reminder/ReminderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,10 @@ private function getAllVEventsFromVCalendar(VObject\Component\VCalendar $vcalend
if ($child->name !== 'VEVENT') {
continue;
}
// Ignore invalid events with no DTSTART
if ($child->DTSTART === null) {
continue;
}

$vevents[] = $child;
}
Expand Down
47 changes: 47 additions & 0 deletions apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,53 @@ public function testOnCalendarObjectCreateSingleEntry():void {
$this->reminderService->onCalendarObjectCreate($objectData);
}

/**
* RFC5545 says DTSTART is REQUIRED, but we have seen event without the prop
*/
public function testOnCalendarObjectCreateNoDtstart(): void {
$calendarData = <<<EOD
BEGIN:VCALENDAR
PRODID:-//Nextcloud calendar v1.6.4
BEGIN:VEVENT
CREATED:20160602T133732
DTSTAMP:20160602T133732
LAST-MODIFIED:20160602T133732
UID:wej2z68l9h
SUMMARY:Test Event
BEGIN:VALARM
ACTION:EMAIL
TRIGGER:-PT15M
END:VALARM
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER;VALUE=DATE-TIME:20160608T000000Z
END:VALARM
END:VEVENT
END:VCALENDAR
EOD;
$objectData = [
'calendardata' => $calendarData,
'id' => '42',
'calendarid' => '1337',
'component' => 'vevent',
];

$this->backend->expects($this->exactly(2))
tcitworld marked this conversation as resolved.
Show resolved Hide resolved
->method('insertReminder')
->withConsecutive(
[1337, 42, 'wej2z68l9h', false, null, false, '5c70531aab15c92b52518ae10a2f78a4', 'de919af7429d3b5c11e8b9d289b411a6', 'EMAIL', true, 1465429500, false],
[1337, 42, 'wej2z68l9h', false, null, false, '5c70531aab15c92b52518ae10a2f78a4', '35b3eae8e792aa2209f0b4e1a302f105', 'DISPLAY', false, 1465344000, false]
)
->willReturn(1);

$this->timeFactory->expects($this->once())
->method('getDateTime')
->with()
->willReturn(DateTime::createFromFormat(DateTime::ATOM, '2016-06-08T00:00:00+00:00'));

$this->reminderService->onCalendarObjectCreate($objectData);
}

public function testOnCalendarObjectCreateSingleEntryWithRepeat(): void {
$objectData = [
'calendardata' => self::CALENDAR_DATA_REPEAT,
Expand Down