]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/APContact.php
Merge pull request #12364 from MrPetovan/bug/warnings
[friendica.git] / src / Model / APContact.php
index 67ce2b66bf73d9c689ef5f778404edc42c1fb358..fd748f1cd4e92419b77513f5cad205a3cec60fcb 100644 (file)
@@ -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'] = '';
                        }
                }