Skip to content

Commit

Permalink
Merge pull request #109 from ProtonMail/mathroc-patch-1
Browse files Browse the repository at this point in the history
throw InvalidDataException when finding invalid RRULE part
  • Loading branch information
mathroc authored Oct 14, 2024
2 parents 3ff67e1 + 388bb3f commit 24fecbb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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

0 comments on commit 24fecbb

Please sign in to comment.