Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/roundcube/roundcubemail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'program/lib/Roundcube/rcube_vcard.php')
-rw-r--r--program/lib/Roundcube/rcube_vcard.php27
1 files changed, 16 insertions, 11 deletions
diff --git a/program/lib/Roundcube/rcube_vcard.php b/program/lib/Roundcube/rcube_vcard.php
index f8499d667..dfa53f206 100644
--- a/program/lib/Roundcube/rcube_vcard.php
+++ b/program/lib/Roundcube/rcube_vcard.php
@@ -836,17 +836,22 @@ class rcube_vcard
{
$vcard = '';
- foreach ((array)$data as $type => $entries) {
- // valid N has 5 properties
- while ($type == "N" && is_array($entries[0]) && count($entries[0]) < 5) {
- $entries[0][] = "";
- }
+ // Make sure FN is not empty (required by RFC2426)
+ if (empty($data['FN'])) {
+ $data['FN'] = !empty($data['EMAIL'][0][0]) ? $data['EMAIL'][0][0] : '';
+ }
- // make sure FN is not empty (required by RFC2426)
- if ($type == "FN" && empty($entries) && !empty($data['EMAIL'][0][0])) {
- $entries[0] = $data['EMAIL'][0][0];
- }
+ // Make sure N is not empty (required by RFC2426)
+ if (empty($data['N'])) {
+ $data['N'] = [['', '', '', '', '']];
+ }
+
+ // Valid N has 5 properties
+ while (isset($data['N'][0]) && is_array($data['N'][0]) && count($data['N'][0]) < 5) {
+ $data['N'][0][] = '';
+ }
+ foreach ((array)$data as $type => $entries) {
foreach ((array)$entries as $entry) {
$attr = '';
if (is_array($entry)) {
@@ -881,8 +886,8 @@ class rcube_vcard
$value = $entry;
}
- // skip empty entries
- if (self::is_empty($value)) {
+ // Skip empty entries that aren't required by vCard v3 format
+ if (!in_array($type, ['N', 'FN']) && self::is_empty($value)) {
continue;
}