Skip to content

Commit

Permalink
Fix colon was used instead of semicolon as param separator (#222)
Browse files Browse the repository at this point in the history
As of section 3.1 of RFC 5545, a content line is defined as follows:

contentline   = name *(";" param ) ":" value CRLF

Therefore, the separator between name and previous parameters must be a semicolon instead of a colon.

Fix #216
  • Loading branch information
markuspoerschke committed Mar 17, 2021
1 parent 9bcaa88 commit 6e91997
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions examples/example1.php
Expand Up @@ -31,8 +31,8 @@
->setDescription('Lorem Ipsum Dolor...')
->setOccurrence(
new TimeSpan(
new DateTime(DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2030-12-24 13:30:00'), false),
new DateTime(DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2030-12-24 14:30:00'), false)
new DateTime(DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2030-12-24 13:30:00'), true),
new DateTime(DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2030-12-24 14:30:00'), true)
)
)
->addAlarm(
Expand Down
2 changes: 1 addition & 1 deletion src/Presentation/Component/Property.php
Expand Up @@ -42,7 +42,7 @@ public function __toString(): string
$string = $this->name;

if (count($this->parameters) > 0) {
$string .= ':' . implode(';', array_map('strval', $this->parameters));
$string .= ';' . implode(';', array_map('strval', $this->parameters));
}

return $string . ':' . $this->value;
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Presentation/Component/PropertyTest.php
Expand Up @@ -42,7 +42,7 @@ public function provideTestData()
[
new Parameter('TEST', new TextValue('value')),
],
'LOREM:TEST=value:Ipsum',
'LOREM;TEST=value:Ipsum',
];

yield 'property with multiple parameters' => [
Expand All @@ -52,7 +52,7 @@ public function provideTestData()
new Parameter('TEST', new TextValue('value')),
new Parameter('TEST2', new TextValue('value2')),
],
'LOREM:TEST=value;TEST2=value2:Ipsum',
'LOREM;TEST=value;TEST2=value2:Ipsum',
];
}
}
8 changes: 4 additions & 4 deletions tests/Unit/Presentation/Factory/AlarmFactoryTest.php
Expand Up @@ -34,7 +34,7 @@ public function testAudioAlarm()
$expected = implode(ContentLine::LINE_SEPARATOR, [
'BEGIN:VALARM',
'ACTION:AUDIO',
'TRIGGER:VALUE=DATE-TIME:20200930T000000',
'TRIGGER;VALUE=DATE-TIME:20200930T000000',
'END:VALARM',
]);

Expand All @@ -58,7 +58,7 @@ public function testEmailAlarm()
'ACTION:EMAIL',
'SUMMARY:Summary Text',
'DESCRIPTION:Description Text',
'TRIGGER:VALUE=DATE-TIME:20200930T000000',
'TRIGGER;VALUE=DATE-TIME:20200930T000000',
'END:VALARM',
]);

Expand All @@ -81,7 +81,7 @@ public function testDisplayAlarm()
'BEGIN:VALARM',
'ACTION:DISPLAY',
'DESCRIPTION:Description Text',
'TRIGGER:VALUE=DATE-TIME:20200930T000000',
'TRIGGER;VALUE=DATE-TIME:20200930T000000',
'END:VALARM',
]);

Expand Down Expand Up @@ -125,7 +125,7 @@ public function testRepeat()
$expected = implode(ContentLine::LINE_SEPARATOR, [
'BEGIN:VALARM',
'ACTION:AUDIO',
'TRIGGER:VALUE=DATE-TIME:20200930T000000',
'TRIGGER;VALUE=DATE-TIME:20200930T000000',
'REPEAT:3',
'DURATION:P1D',
'END:VALARM',
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Presentation/Factory/DateTimeFactoryTest.php
Expand Up @@ -25,6 +25,6 @@ public function testCreateProperty(): void

$property = (new DateTimeFactory())->createProperty('DTSTART', $dateTime);

self::assertSame('DTSTART:TZID=Europe/Berlin:20210122T111213', $property->__toString());
self::assertSame('DTSTART;TZID=Europe/Berlin:20210122T111213', $property->__toString());
}
}
4 changes: 2 additions & 2 deletions tests/Unit/Presentation/Factory/EventFactoryTest.php
Expand Up @@ -127,7 +127,7 @@ public function testUrlAttachments()
);

self::assertEventRendersCorrect($event, [
'ATTACH:FMTTYPE=text/plain:http://example.com/document.txt',
'ATTACH;FMTTYPE=text/plain:http://example.com/document.txt',
]);
}

Expand All @@ -142,7 +142,7 @@ public function testFileAttachments()
);

self::assertEventRendersCorrect($event, [
'ATTACH:FMTTYPE=text/plain;ENCODING=BASE64;VALUE=BINARY:SGVsbG8gV29ybGQh',
'ATTACH;FMTTYPE=text/plain;ENCODING=BASE64;VALUE=BINARY:SGVsbG8gV29ybGQh',
]);
}

Expand Down

0 comments on commit 6e91997

Please sign in to comment.