Skip to content

Commit

Permalink
Merge pull request #692 from mathroc/patch-1
Browse files Browse the repository at this point in the history
Throw InvalidDataException when RRule is invalid
  • Loading branch information
phil-davis authored Oct 14, 2024
2 parents 28e191b + ab14f5e commit 53f73a4
Show file tree
Hide file tree
Showing 2 changed files with 17 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
9 changes: 9 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,14 @@ public function testValidateStripNoFreq(): void
);
}

public function testUnrepairableRRule(): void
{
$this->expectException(InvalidDataException::class);
$calendar = new VCalendar();
$property = $calendar->createProperty('RRULE', 'IAmNotARRule');
$property->validate(Node::REPAIR);
}

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

0 comments on commit 53f73a4

Please sign in to comment.