diff --git a/program/lib/Roundcube/rcube_vcard.php b/program/lib/Roundcube/rcube_vcard.php index 9552ba58212..8ef581b8b67 100644 --- a/program/lib/Roundcube/rcube_vcard.php +++ b/program/lib/Roundcube/rcube_vcard.php @@ -681,7 +681,7 @@ public static function rfc2425_fold($val) private static function vcard_decode($vcard) { // Perform RFC2425 line unfolding and split lines - $vcard = preg_replace(["/\r/", "/\n\\s+/"], '', $vcard); + $vcard = str_replace(["\r", "\n ", "\n\t"], '', $vcard); $lines = explode("\n", $vcard); $result = []; @@ -985,7 +985,7 @@ private static function detect_encoding($string) // This will for example exclude photos // Perform RFC2425 line unfolding and split lines - $string = preg_replace(["/\r/", "/\n\\s+/"], '', $string); + $string = str_replace(["\r", "\n ", "\n\t"], '', $string); $lines = explode("\n", $string); $string = ''; diff --git a/tests/Framework/VCardTest.php b/tests/Framework/VCardTest.php index 4d933ae2291..504035e9bc2 100644 --- a/tests/Framework/VCardTest.php +++ b/tests/Framework/VCardTest.php @@ -99,6 +99,28 @@ public function test_parse_six() $this->assertCount(1, $result['address:work'], 'ITEM1.-prefixed entry'); } + /** + * Extra whitespace at start of continuation line (#9593/1). + */ + public function test_parse_continuation_line_with_initial_whitespace() + { + $vcard_string = <<<'EOF' + BEGIN:VCARD + VERSION:3.0 + N:Doe;Jane;;; + FN:Jane Doe + NOTE:an + example + END:VCARD + EOF; + + $vcard = new \rcube_vcard(str_replace("\n", "\r\n", $vcard_string) . "\r\n"); + + $result = $vcard->get_assoc(); + + $this->assertSame('an example', $result['notes'][0]); + } + public function test_import() { $input = file_get_contents($this->_srcpath('apple.vcf'));