diff --git a/lib/Parser/MimeDir.php b/lib/Parser/MimeDir.php index b0b52d223..a33771619 100644 --- a/lib/Parser/MimeDir.php +++ b/lib/Parser/MimeDir.php @@ -215,12 +215,20 @@ protected function parseLine($line) && $e instanceof ParseException && str_contains($e->getMessage(), 'Invalid Mimedir file. Line starting at') && ($this->options & Reader::OPTION_FIX_UNFOLDING) ) { - // Fix unfolding - $component->remove($prevNode); - $value = $prevNode->getValue() . ' ' . $line . PHP_EOL; - $prevNode->offsetSet('VALUE', $value); - $prevNode->setValue($value); - $component->add($prevNode); + if (preg_match('/[A-Z]\w+; /', $line)) { + $line = preg_replace('/([A-Z]\w+;) /', '$1', $line); + $result = $this->parseLine($line); + if ($result) { + $prevNode = $component->add($result); + } + } else { + // Fix unfolding + $component->remove($prevNode); + $value = $prevNode->getValue() . ' ' . $line . PHP_EOL; + $prevNode->offsetSet('VALUE', $value); + $prevNode->setValue($value); + $component->add($prevNode); + } continue; } throw $e; diff --git a/tests/VObject/Parser/UnfoldingTest.php b/tests/VObject/Parser/UnfoldingTest.php index 8d751ae7a..56c9e28e4 100644 --- a/tests/VObject/Parser/UnfoldingTest.php +++ b/tests/VObject/Parser/UnfoldingTest.php @@ -96,4 +96,31 @@ public function testNotFixUnknownProperty() $this->assertNotNull($vcard->children()[0]->CONFERENCE->getValue()); } + + public function testRemoveEmptySpaceAfterColon(): void + { + $vcard = <<parse($vcard, Reader::OPTION_FIX_UNFOLDING | Reader::OPTION_FORGIVING); + + + $this->assertSame( + 0, + $vcard->VEVENT->SEQUENCE->getValue() + ); + + $this->assertSame( + 'ORGANIZER;CN=Plannert:mailto:noreply@sho.nl' . "\r\n", + $vcard->VEVENT->ORGANIZER->serialize() + ); + } }