From e256876ec1c1f59ba86374a8dc2c921b0d8abcd9 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 24 Jul 2019 19:30:36 +0000 Subject: [PATCH] Support for empty nick names --- src/Model/APContact.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Model/APContact.php b/src/Model/APContact.php index 82afc07696..e7191d32e8 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -153,7 +153,7 @@ class APContact extends BaseObject self::unarchiveInbox($apcontact['sharedinbox'], true); } - $apcontact['nick'] = JsonLD::fetchElement($compacted, 'as:preferredUsername', '@value'); + $apcontact['nick'] = JsonLD::fetchElement($compacted, 'as:preferredUsername', '@value') ?? ''; $apcontact['name'] = JsonLD::fetchElement($compacted, 'as:name', '@value'); if (empty($apcontact['name'])) { @@ -185,7 +185,12 @@ class APContact extends BaseObject $parts = parse_url($apcontact['url']); unset($parts['scheme']); unset($parts['path']); - $apcontact['addr'] = $apcontact['nick'] . '@' . str_replace('//', '', Network::unparseURL($parts)); + + if (!empty($apcontact['nick'])) { + $apcontact['addr'] = $apcontact['nick'] . '@' . str_replace('//', '', Network::unparseURL($parts)); + } else { + $apcontact['addr'] = ''; + } if (!empty($compacted['w3id:publicKey'])) { $apcontact['pubkey'] = trim(JsonLD::fetchElement($compacted['w3id:publicKey'], 'w3id:publicKeyPem', '@value')); -- 2.39.5