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

throw InvalidDataException when finding invalid RRULE part #109

Merged
merged 4 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 8 additions & 1 deletion lib/Property/ICalendar/Recur.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,14 @@ public static function stringToArray(string $value): array
if (empty($part)) {
continue;
}
list($partName, $partValue) = explode('=', $part);

$parts = explode('=', $part);

if (2 !== count($parts)) {
throw new InvalidDataException('The supplied iCalendar RRULE part is incorrect: '.$part);
}

list($partName, $partValue) = $parts;

// The value itself had multiple values..
if (false !== strpos($partValue, ',')) {
Expand Down
10 changes: 10 additions & 0 deletions tests/VObject/Property/ICalendar/RecurTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use PHPUnit\Framework\TestCase;
use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\InvalidDataException;
use Sabre\VObject\Node;
use Sabre\VObject\Reader;

Expand Down Expand Up @@ -194,6 +195,15 @@ public function testValidateStripNoFreq(): void
);
}

public function testUnrepairableRRule(): void
{
$calendar = new VCalendar();

$this->expectException(InvalidDataException::class);

$property = $calendar->createProperty('RRULE', 'IAmNotARRule');
}

public function testValidateInvalidByMonthRruleWithRepair(): void
{
$calendar = new VCalendar();
Expand Down
Loading