From e7574356d83ec698afcc942103c0aa1c14000860 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 7 Dec 2022 22:08:48 -0500 Subject: [PATCH] Replace parse_url with UriInterface instantiation in Model\APContact - Address part of https://github.com/friendica/friendica/issues/12011#issuecomment-1338133783 --- src/Model/APContact.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Model/APContact.php b/src/Model/APContact.php index 67ce2b66bf..fd748f1cd4 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -291,14 +291,11 @@ class APContact return $fetched_contact; } - $parts = parse_url($apcontact['url']); - unset($parts['scheme']); - unset($parts['path']); - if (empty($apcontact['addr'])) { - if (!empty($apcontact['nick']) && is_array($parts)) { - $apcontact['addr'] = $apcontact['nick'] . '@' . str_replace('//', '', Network::unparseURL($parts)); - } else { + try { + $apcontact['addr'] = $apcontact['nick'] . '@' . (new Uri($apcontact['url']))->getAuthority(); + } catch (\Throwable $e) { + Logger::warning('Unable to coerce APContact URL into a UriInterface object', ['url' => $apcontact['url'], 'error' => $e->getMessage()]); $apcontact['addr'] = ''; } } -- 2.39.5