From 3773a76988df2b4613b3f512ad01be7f3742ef99 Mon Sep 17 00:00:00 2001 From: Mathieu Rochette Date: Fri, 11 Oct 2024 16:41:38 +0200 Subject: [PATCH 1/4] throw InvalidDataException when finding invalid RRULE part --- lib/Property/ICalendar/Recur.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Property/ICalendar/Recur.php b/lib/Property/ICalendar/Recur.php index 9a1e9e643..b229e87ab 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 (count($parts) !== 2) { + 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, ',')) { From de36f61e43dd7ed9bf33749887b53b54b843b0f3 Mon Sep 17 00:00:00 2001 From: Mathieu Rochette Date: Fri, 11 Oct 2024 16:45:53 +0200 Subject: [PATCH 2/4] . --- lib/Property/ICalendar/Recur.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Property/ICalendar/Recur.php b/lib/Property/ICalendar/Recur.php index b229e87ab..10081673e 100644 --- a/lib/Property/ICalendar/Recur.php +++ b/lib/Property/ICalendar/Recur.php @@ -192,7 +192,7 @@ public static function stringToArray(string $value): array $parts = explode('=', $part); - if (count($parts) !== 2) { + if (2 !== count($parts)) { throw new InvalidDataException('The supplied iCalendar RRULE part is incorrect: '.$part); } From 43bc8e3aba7569043f5bc5577ebd7c8f08940129 Mon Sep 17 00:00:00 2001 From: Mathieu Rochette Date: Fri, 11 Oct 2024 17:10:01 +0200 Subject: [PATCH 3/4] . --- tests/VObject/Property/ICalendar/RecurTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/VObject/Property/ICalendar/RecurTest.php b/tests/VObject/Property/ICalendar/RecurTest.php index b2750f03b..0adf30215 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,16 @@ public function testValidateStripNoFreq(): void ); } + public function testUnrepairableRRule(): void + { + $calendar = new VCalendar(); + $property = $calendar->createProperty('RRULE', 'IAmNotARRule'); + + $this->expectException(InvalidDataException::class); + + $property->validate(Node::REPAIR); + } + public function testValidateInvalidByMonthRruleWithRepair(): void { $calendar = new VCalendar(); From 388bb3f4a2d0eebededb89932f4239fc74852a3d Mon Sep 17 00:00:00 2001 From: Mathieu Rochette Date: Fri, 11 Oct 2024 17:12:47 +0200 Subject: [PATCH 4/4] . --- tests/VObject/Property/ICalendar/RecurTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/VObject/Property/ICalendar/RecurTest.php b/tests/VObject/Property/ICalendar/RecurTest.php index 0adf30215..29096e9de 100644 --- a/tests/VObject/Property/ICalendar/RecurTest.php +++ b/tests/VObject/Property/ICalendar/RecurTest.php @@ -198,11 +198,10 @@ public function testValidateStripNoFreq(): void public function testUnrepairableRRule(): void { $calendar = new VCalendar(); - $property = $calendar->createProperty('RRULE', 'IAmNotARRule'); $this->expectException(InvalidDataException::class); - $property->validate(Node::REPAIR); + $property = $calendar->createProperty('RRULE', 'IAmNotARRule'); } public function testValidateInvalidByMonthRruleWithRepair(): void