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

Ignore multiple same parameter-values #577

Merged
merged 2 commits into from
Jul 15, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}