Fix handling of empty entries in vCard import (#6564)

pull/6576/head
Aleksander Machniak 6 years ago
parent 4619f030f2
commit 8dec8fb60a

@ -2,6 +2,7 @@ CHANGELOG Roundcube Webmail
===========================
- Fix bug where a message/rfc822 part without a filename wasn't listed on the attachments list (#6494)
- Fix handling of empty entries in vCard import (#6564)
RELEASE 1.3.8
-------------

@ -673,8 +673,10 @@ class rcube_vcard
$data = self::vcard_unquote($data);
}
$entry = array_merge($entry, (array) $data);
$result[$field][] = $entry;
if (is_array($data) || (is_string($data) && strlen($data))) {
$entry = array_merge($entry, (array) $data);
$result[$field][] = $entry;
}
}
}
@ -812,7 +814,10 @@ class rcube_vcard
if (count($parts = explode($sep, strtr($s, $rep1))) > 1) {
foreach ($parts as $s) {
$result[] = self::vcard_unquote(strtr($s, $rep2));
$s = self::vcard_unquote(strtr($s, $rep2));
if (is_array($s) || (is_string($s) && strlen($s))) {
$result[] = $s;
}
}
return $result;
}

@ -151,4 +151,24 @@ class Framework_VCard extends PHPUnit_Framework_TestCase
$vcards = rcube_vcard::import($input);
$this->assertEquals("Ǽgean ĽdaMonté", $vcards[0]->displayname, "Decoded from UTF-16");
}
/**
* Skipping empty values (#6564)
*/
function test_parse_skip_empty()
{
$vcard = new rcube_vcard("BEGIN:VCARD\n"
. "VERSION:3.0\n"
. "N:;;;;\n"
. "FN:Test\n"
. "TEL;TYPE=home:67890\n"
. "TEL;TYPE=CELL:\n"
. "END:VCARD"
);
$result = $vcard->get_assoc();
$this->assertCount(1, $result['phone:home'], "TYPE=home entry exists");
$this->assertTrue(!isset($result['phone:mobile']), "TYPE=CELL entry ignored");
}
}

Loading…
Cancel
Save