Skip to content

Commit 72ec4ce

Browse files
authored
Merge pull request sabre-io#696 from phil-davis/rrule-invalid-4.5
[4.5] Throw InvalidDataException when RRule is invalid
2 parents 7044047 + 8b3e5d2 commit 72ec4ce

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/Property/ICalendar/Recur.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Sabre\VObject\Property\ICalendar;
44

5+
use Sabre\VObject\InvalidDataException;
56
use Sabre\VObject\Property;
67
use Sabre\Xml;
78

@@ -198,7 +199,14 @@ public static function stringToArray($value)
198199
if (empty($part)) {
199200
continue;
200201
}
201-
list($partName, $partValue) = explode('=', $part);
202+
203+
$parts = explode('=', $part);
204+
205+
if (2 !== count($parts)) {
206+
throw new InvalidDataException('The supplied iCalendar RRULE part is incorrect: '.$part);
207+
}
208+
209+
list($partName, $partValue) = $parts;
202210

203211
// The value itself had multiple values..
204212
if (false !== strpos($partValue, ',')) {

tests/VObject/Property/ICalendar/RecurTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PHPUnit\Framework\TestCase;
66
use Sabre\VObject\Component\VCalendar;
7+
use Sabre\VObject\InvalidDataException;
78
use Sabre\VObject\Node;
89
use Sabre\VObject\Reader;
910

@@ -194,6 +195,14 @@ public function testValidateStripNoFreq()
194195
);
195196
}
196197

198+
public function testUnrepairableRRule()
199+
{
200+
$this->expectException(InvalidDataException::class);
201+
$calendar = new VCalendar();
202+
$property = $calendar->createProperty('RRULE', 'IAmNotARRule');
203+
$property->validate(Node::REPAIR);
204+
}
205+
197206
public function testValidateInvalidByMonthRruleWithRepair()
198207
{
199208
$calendar = new VCalendar();

0 commit comments

Comments
 (0)