]> git.mxchange.org Git - friendica.git/commitdiff
Merge remote-tracking branch 'upstream/develop' into sanitize-gcontact
authorMichael <heluecht@pirati.ca>
Tue, 15 Oct 2019 10:10:12 +0000 (10:10 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 15 Oct 2019 10:10:12 +0000 (10:10 +0000)
1  2 
src/Model/GContact.php

index b16bedd7b946e78d4ae8fcff5879282edc926855,d6d69e98c2acd55b9591524887f28e51a8ff7f90..1ece56306523dc80de060bed4bfd1d5dac5156b6
@@@ -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'];
                        }
                }
  
                        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;