Mercurial > hg > rc2
diff program/lib/Roundcube/rcube_vcard.php @ 22:303b85d5b561
More cleaning up php8 Warnings/deprecations
| author | Charlie Root |
|---|---|
| date | Wed, 15 Oct 2025 14:06:27 -0400 |
| parents | 73124dd49283 |
| children | bea5a38be938 |
line wrap: on
line diff
--- a/program/lib/Roundcube/rcube_vcard.php Thu Oct 09 11:31:41 2025 -0400 +++ b/program/lib/Roundcube/rcube_vcard.php Wed Oct 15 14:06:27 2025 -0400 @@ -126,15 +126,20 @@ // find well-known address fields $this->displayname = $this->raw['FN'][0][0]; - $this->surname = $this->raw['N'][0][0]; - $this->firstname = $this->raw['N'][0][1]; - $this->middlename = $this->raw['N'][0][2]; + if (!empty($this->raw['N'])) { + $this->surname = $this->raw['N'][0][0]; + $this->firstname = $this->raw['N'][0][1]; + $this->middlename = $this->raw['N'][0][2]; + } $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)); + $this->business = (isset($this->raw['X-ABSHOWAS'][0][0]) && $this->raw['X-ABSHOWAS'][0][0] == 'COMPANY') + || (!empty($this->organization) && isset($this->raw['N'][0]) && @implode('', (array) $this->raw['N'][0]) === ''); - foreach ((array)$this->raw['EMAIL'] as $i => $raw_email) { - $this->email[$i] = is_array($raw_email) ? $raw_email[0] : $raw_email; + if (!empty($this->raw['EMAIL'])) { + foreach ((array) $this->raw['EMAIL'] as $i => $raw_email) { + $this->email[$i] = is_array($raw_email) ? $raw_email[0] : $raw_email; + } } // make the pref e-mail address the first entry in $this->email @@ -168,11 +173,12 @@ } } - if ($this->raw['N'][0][3]) + if (!empty($this->raw['N'])) { + if ($this->raw['N'][0][3]) $out['prefix'] = $this->raw['N'][0][3]; - if ($this->raw['N'][0][4]) + if ($this->raw['N'][0][4]) $out['suffix'] = $this->raw['N'][0][4]; - + } // convert from raw vcard data into associative data for Roundcube foreach (array_flip(self::$fieldmap) as $tag => $col) { if (!empty($this->raw[$tag])) { @@ -186,21 +192,29 @@ $combined = join(',', self::array_filter((array)$raw['type'], 'internet,pref', true)); $combined = strtoupper($combined); - if ($typemap[$combined]) { + if (!empty($typemap[$combined])) { $subtype = $typemap[$combined]; } - else if ($typemap[$raw['type'][++$k]]) { + else if (!empty($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 == 'interne +t' || $subtype == 'pref')) { + $k++; + if (!empty($raw['type'][$k])) { + if (!empty($typemap[$raw['type'][$k]])) { + $subtype = $typemap[$raw['type'][$k]]; + } + else { + $subtype = $raw['type'][$k]; + } + } } } - // read vcard 2.1 subtype if (!$subtype) { foreach ($raw as $k => $v) { @@ -241,13 +255,15 @@ // handle special IM fields as used by Apple foreach ($this->immap as $tag => $type) { - foreach ((array)$this->raw[$tag] as $i => $raw) { + if (!empty($this->raw[$tag])) { + foreach ((array)$this->raw[$tag] as $i => $raw) { $out['im:'.$type][] = $raw[0]; - } + } + } } // copy photo data - if ($this->raw['PHOTO']) { + if (!empty($this->raw['PHOTO'])) { $out['photo'] = $this->raw['PHOTO'][0][0]; }
