From: Michael Date: Tue, 15 Oct 2019 10:10:12 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/develop' into sanitize-gcontact X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f1e7d97b8cae93e1c77f5a5085880409b01fcdbe;p=friendica.git Merge remote-tracking branch 'upstream/develop' into sanitize-gcontact --- f1e7d97b8cae93e1c77f5a5085880409b01fcdbe diff --cc src/Model/GContact.php index b16bedd7b9,d6d69e98c2..1ece563065 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@@ -140,51 -143,52 +145,51 @@@ class GContac } // Assure that there are no parameter fragments in the profile url - if (in_array($gcontact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ''])) { - if (empty($gcontact["network"]) || in_array($gcontact["network"], Protocol::FEDERATED)) { ++ if (empty($gcontact['*network']) || in_array($gcontact["network"], Protocol::FEDERATED)) { $gcontact['url'] = self::cleanContactUrl($gcontact['url']); } $alternate = PortableContact::alternateOStatusUrl($gcontact['url']); // The global contacts should contain the original picture, not the cached one - if (($gcontact['generation'] != 1) && stristr(normalise_link($gcontact['photo']), normalise_link(System::baseUrl().'/photo/'))) { - if (($gcontact['generation'] != 1) && stristr(Strings::normaliseLink($gcontact['photo']), Strings::normaliseLink(System::baseUrl()."/photo/"))) { - $gcontact['photo'] = ""; ++ if (($gcontact['generation'] != 1) && stristr(Strings::normaliseLink($gcontact['photo']), Strings::normaliseLink(System::baseUrl() . '/photo/'))) { + $gcontact['photo'] = ''; } - if (!isset($gcontact['network'])) { + if (empty($gcontact['network'])) { + $gcontact['network'] = ''; + $condition = ["`uid` = 0 AND `nurl` = ? AND `network` != '' AND `network` != ?", - normalise_link($gcontact['url']), Protocol::STATUSNET]; + Strings::normaliseLink($gcontact['url']), Protocol::STATUSNET]; $contact = DBA::selectFirst('contact', ['network'], $condition); if (DBA::isResult($contact)) { - $gcontact['network'] = $contact["network"]; + $gcontact['network'] = $contact['network']; } - if (($gcontact['network'] == "") || ($gcontact['network'] == Protocol::OSTATUS)) { + if (($gcontact['network'] == '') || ($gcontact['network'] == Protocol::OSTATUS)) { $condition = ["`uid` = 0 AND `alias` IN (?, ?) AND `network` != '' AND `network` != ?", - $gcontact['url'], normalise_link($gcontact['url']), Protocol::STATUSNET]; + $gcontact['url'], Strings::normaliseLink($gcontact['url']), Protocol::STATUSNET]; $contact = DBA::selectFirst('contact', ['network'], $condition); if (DBA::isResult($contact)) { - $gcontact['network'] = $contact["network"]; + $gcontact['network'] = $contact['network']; } } } - $gcontact['server_url'] = ''; - $gcontact['network'] = ''; - $fields = ['network', 'updated', 'server_url', 'url', 'addr']; - $gcnt = DBA::selectFirst('gcontact', $fields, ['nurl' => normalise_link($gcontact['url'])]); + $gcnt = DBA::selectFirst('gcontact', $fields, ['nurl' => Strings::normaliseLink($gcontact['url'])]); if (DBA::isResult($gcnt)) { - if (!isset($gcontact['network']) && ($gcnt["network"] != Protocol::STATUSNET)) { - $gcontact['network'] = $gcnt["network"]; + if (!isset($gcontact['network']) && ($gcnt['network'] != Protocol::STATUSNET)) { + $gcontact['network'] = $gcnt['network']; } if ($gcontact['updated'] <= DBA::NULL_DATETIME) { - $gcontact['updated'] = $gcnt["updated"]; + $gcontact['updated'] = $gcnt['updated']; } - if (!isset($gcontact['server_url']) && (normalise_link($gcnt['server_url']) != normalise_link($gcnt['url']))) { - if (!isset($gcontact['server_url']) && (Strings::normaliseLink($gcnt["server_url"]) != Strings::normaliseLink($gcnt["url"]))) { - $gcontact['server_url'] = $gcnt["server_url"]; ++ if (!isset($gcontact['server_url']) && (Strings::normaliseLink($gcnt['server_url']) != Strings::normaliseLink($gcnt['url']))) { + $gcontact['server_url'] = $gcnt['server_url']; } if (!isset($gcontact['addr'])) { - $gcontact['addr'] = $gcnt["addr"]; + $gcontact['addr'] = $gcnt['addr']; } } @@@ -219,19 -223,19 +224,19 @@@ throw new Exception('No federated network ('.$gcontact['network'].') detected for URL '.$gcontact['url']); } - if (!isset($gcontact['server_url'])) { + if (empty($gcontact['server_url'])) { // We check the server url to be sure that it is a real one - $server_url = PortableContact::detectServer($gcontact['url']); + $server_url = Contact::getBasepath($gcontact['url']); // We are now sure that it is a correct URL. So we use it in the future - if ($server_url != "") { + if ($server_url != '') { $gcontact['server_url'] = $server_url; } } // The server URL doesn't seem to be valid, so we don't store it. - if (!PortableContact::checkServer($gcontact['server_url'], $gcontact['network'])) { + if (!GServer::check($gcontact['server_url'], $gcontact['network'])) { - $gcontact['server_url'] = ""; + $gcontact['server_url'] = ''; } return $gcontact;