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

vcard: Fix whitespace handling in line cont's #9637

Merged
merged 3 commits into from
Sep 18, 2024
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
4 changes: 2 additions & 2 deletions program/lib/Roundcube/rcube_vcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand Down Expand Up @@ -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 = '';

Expand Down
22 changes: 22 additions & 0 deletions tests/Framework/VCardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down