diff --git a/lib/Property/ICalendar/Recur.php b/lib/Property/ICalendar/Recur.php index 9a1e9e643..10081673e 100644 --- a/lib/Property/ICalendar/Recur.php +++ b/lib/Property/ICalendar/Recur.php @@ -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, ',')) { diff --git a/tests/VObject/Property/ICalendar/RecurTest.php b/tests/VObject/Property/ICalendar/RecurTest.php index b2750f03b..29096e9de 100644 --- a/tests/VObject/Property/ICalendar/RecurTest.php +++ b/tests/VObject/Property/ICalendar/RecurTest.php @@ -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; @@ -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();