Mercurial > hg > rc2
diff program/lib/Roundcube/rcube_vcard.php @ 21:73124dd49283
More cleaning up php8 Warnings/deprecations,
noticed that setting non-my-Dates mailboxes to sort on Date isn't sticky over ctrl-R
| author | Charlie Root |
|---|---|
| date | Thu, 09 Oct 2025 11:31:41 -0400 |
| parents | 5039cc34571f |
| children | 303b85d5b561 |
line wrap: on
line diff
--- a/program/lib/Roundcube/rcube_vcard.php Wed Oct 08 09:42:21 2025 -0400 +++ b/program/lib/Roundcube/rcube_vcard.php Thu Oct 09 11:31:41 2025 -0400 @@ -129,8 +129,8 @@ $this->surname = $this->raw['N'][0][0]; $this->firstname = $this->raw['N'][0][1]; $this->middlename = $this->raw['N'][0][2]; - $this->nickname = $this->raw['NICKNAME'][0][0]; - $this->organization = $this->raw['ORG'][0][0]; + $this->nickname = empty($this->raw['NICKNAME']) ? null : $this->raw['NICKNAME'][0][0]; + $this->organization = empty($this->raw['ORG']) ? null : $this->raw['ORG'][0][0]; $this->business = ($this->raw['X-ABSHOWAS'][0][0] == 'COMPANY') || (join('', (array)$this->raw['N'][0]) == '' && !empty($this->organization)); foreach ((array)$this->raw['EMAIL'] as $i => $raw_email) { @@ -163,7 +163,7 @@ // copy name fields to output array foreach (array('firstname','surname','middlename','nickname','organization') as $col) { - if (strlen($this->$col)) { + if (!empty($this->$col) && strlen($this->$col)) { $out[$col] = $this->$col; } } @@ -175,66 +175,68 @@ // convert from raw vcard data into associative data for Roundcube foreach (array_flip(self::$fieldmap) as $tag => $col) { - foreach ((array)$this->raw[$tag] as $i => $raw) { - if (is_array($raw)) { - $k = -1; - $key = $col; - $subtype = ''; + if (!empty($this->raw[$tag])) { + foreach ((array)$this->raw[$tag] as $i => $raw) { + if (is_array($raw)) { + $k = -1; + $key = $col; + $subtype = ''; - if (!empty($raw['type'])) { - $combined = join(',', self::array_filter((array)$raw['type'], 'internet,pref', true)); - $combined = strtoupper($combined); + if (!empty($raw['type'])) { + $combined = join(',', self::array_filter((array)$raw['type'], 'internet,pref', true)); + $combined = strtoupper($combined); - if ($typemap[$combined]) { - $subtype = $typemap[$combined]; - } - else if ($typemap[$raw['type'][++$k]]) { - $subtype = $typemap[$raw['type'][$k]]; - } - else { - $subtype = strtolower($raw['type'][$k]); - } + if ($typemap[$combined]) { + $subtype = $typemap[$combined]; + } + else if ($typemap[$raw['type'][++$k]]) { + $subtype = $typemap[$raw['type'][$k]]; + } + else { + $subtype = strtolower($raw['type'][$k]); + } - while ($k < count($raw['type']) && ($subtype == 'internet' || $subtype == 'pref')) { - $subtype = $typemap[$raw['type'][++$k]] ?: strtolower($raw['type'][$k]); - } - } + while ($k < count($raw['type']) && ($subtype == 'internet' || $subtype == 'pref')) { + $subtype = $typemap[$raw['type'][++$k]] ?: strtolower($raw['type'][$k]); + } + } - // read vcard 2.1 subtype - if (!$subtype) { - foreach ($raw as $k => $v) { - if (!is_numeric($k) && $v === true && ($k = strtolower($k)) - && !in_array($k, array('pref','internet','voice','base64')) - ) { - $k_uc = strtoupper($k); - $subtype = $typemap[$k_uc] ?: $k; - break; - } - } - } + // read vcard 2.1 subtype + if (!$subtype) { + foreach ($raw as $k => $v) { + if (!is_numeric($k) && $v === true && ($k = strtolower($k)) + && !in_array($k, array('pref','internet','voice','base64')) + ) { + $k_uc = strtoupper($k); + $subtype = $typemap[$k_uc] ?: $k; + break; + } + } + } - // force subtype if none set - if (!$subtype && preg_match('/^(email|phone|address|website)/', $key)) { - $subtype = 'other'; - } + // force subtype if none set + if (!$subtype && preg_match('/^(email|phone|address|website)/', $key)) { + $subtype = 'other'; + } - if ($subtype) { - $key .= ':' . $subtype; - } + if ($subtype) { + $key .= ':' . $subtype; + } - // split ADR values into assoc array - if ($tag == 'ADR') { - list(,, $value['street'], $value['locality'], $value['region'], $value['zipcode'], $value['country']) = $raw; - $out[$key][] = $value; - } - else { - $out[$key][] = $raw[0]; - } - } - else { - $out[$col][] = $raw; - } - } + // split ADR values into assoc array + if ($tag == 'ADR') { + list(,, $value['street'], $value['locality'], $value['region'], $value['zipcode'], $value['country']) = $raw; + $out[$key][] = $value; + } + else { + $out[$key][] = $raw[0]; + } + } + else { + $out[$col][] = $raw; + } + } + } } // handle special IM fields as used by Apple @@ -611,7 +613,7 @@ } // convert 2.1-style "EMAIL;internet;home:" to 3.0-style "EMAIL;TYPE=internet;TYPE=home:" - if ($result['VERSION'][0] == "2.1" + if (!empty($result['VERSION']) && $result['VERSION'][0] == "2.1" && preg_match('/^([^;]+);([^:]+)/', $prefix, $regs2) && !preg_match('/^TYPE=/i', $regs2[2]) ) { @@ -621,7 +623,8 @@ } } - if (preg_match_all('/([^\\;]+);?/', $prefix, $regs2)) { + if (preg_match_all('/([^\\;]+);?/', $prefix, $regs2) && + count($regs2) > 0) { $entry = array(); $field = strtoupper($regs2[1][0]); $enc = null;
