Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for trailing ; in RRULE #307

Merged
merged 3 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ICal/ICal.php
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ protected function processRecurrences()

// Separate the RRULE stanzas, and explode the values that are lists.
$rrules = array();
foreach (explode(';', $anEvent['RRULE']) as $s) {
foreach (array_filter(explode(';', $anEvent['RRULE'])) as $s) {
list($k, $v) = explode('=', $s);
if (in_array($k, array('BYSETPOS', 'BYDAY', 'BYMONTHDAY', 'BYMONTH', 'BYYEARDAY', 'BYWEEKNO'))) {
$rrules[$k] = explode(',', $v);
Expand Down
21 changes: 20 additions & 1 deletion tests/rfc5545RecurrenceExamplesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
* The following tests are based on the event recurrence examples given
* in the RFC5545 iCal specification (https://tools.ietf.org/html/rfc5545,
* in the RFC5545 iCal specification (https://datatracker.ietf.org/doc/html/rfc5545,
* pages 123 to 132).
*
* Whilst this might not catch edge-cases, it does give a basic set of
Expand Down Expand Up @@ -101,6 +101,25 @@ public function test_page123_test2()
);
}

// Page 123, Test 3 :: Daily, until December 24th, with trailing semicolon
public function test_page123_test3()
{
$checks = array(
array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
array('index' => 1, 'dateString' => '19970903T090000', 'message' => '2nd occurrence: '),
array('index' => 2, 'dateString' => '19970904T090000', 'message' => '3rd occurrence: '),
);
$this->assertVEVENT(
'America/New_York',
array(
'DTSTART;TZID=America/New_York:19970902T090000',
'RRULE:FREQ=DAILY;UNTIL=19971224T000000Z;',
),
113,
$checks
);
}

// Page 124, Test 1 :: Daily, every other day, Forever
//
// UNTIL rule does not exist in original example
Expand Down