Skip to content

Commit

Permalink
Merge pull request #577 from heiglandreas/fixMultipleProperties
Browse files Browse the repository at this point in the history
Ignore multiple same parameter-values
  • Loading branch information
phil-davis authored Jul 15, 2022
2 parents b8a44ea + 404e548 commit 0fdd1d1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/Parser/MimeDir.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ protected function readProperty($line)
$property['parameters'][$lastParam] = $value;
} elseif (is_array($property['parameters'][$lastParam])) {
$property['parameters'][$lastParam][] = $value;
} elseif ($property['parameters'][$lastParam] === $value) {
// When the current value of the parameter is the same as the
// new one, then we can leave the current parameter as it is.
} else {
$property['parameters'][$lastParam] = [
$property['parameters'][$lastParam],
Expand Down
20 changes: 20 additions & 0 deletions tests/VObject/Parser/MimeDirTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,24 @@ public function testCaseInsensitiveInlineCharset()
$this->assertEquals('Euro', $vcard->FN->getValue());
$this->assertEquals('Test2', $vcard->N->getValue());
}

public function testParsingTwiceSameContent()
{
$card = <<<EOF
BEGIN:VCALENDAR
VERSION:2.0
PRODID:PRODID
BEGIN:VEVENT
DTSTAMP;TZID=Europe/Busingen:20220712T172312
UID:UID
DTSTART;VALUE=DATE;VALUE=DATE;VALUE=DATE:20220612
END:VEVENT
END:VCALENDAR
EOF;

$mimeDir = new MimeDir();
$vcard = $mimeDir->parse($card);
// we can do a simple assertion here. As long as we don't get an exception, everything is fine
$this->assertEquals('20220612', $vcard->VEVENT->DTSTART->getValue());
}
}

0 comments on commit 0fdd1d1

Please sign in to comment.