]> git.mxchange.org Git - friendica.git/commitdiff
Improved block check for redirects
authorMichael <heluecht@pirati.ca>
Sun, 22 Jan 2023 12:33:38 +0000 (12:33 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 22 Jan 2023 12:33:38 +0000 (12:33 +0000)
src/Model/GServer.php
src/Worker/UpdateServerPeers.php

index 41edb6c8d271568e47b5647809d9b80649fc28c7..7e3f0f480238f8754efe32058744e58d7ea0a49c 100644 (file)
@@ -474,14 +474,6 @@ class GServer
                        return;
                }
 
-               if (Network::isUrlBlocked($url)) {
-                       Logger::info('Server domain is blocked', ['url' => $url]);
-                       return;
-               } elseif (Network::isUrlBlocked($nurl)) {
-                       Logger::info('Server domain is blocked', ['nurl' => $nurl]);
-                       return;
-               }
-
                self::insert(['url' => $url, 'nurl' => $nurl,
                        'network' => Protocol::PHANTOM, 'created' => DateTimeFormat::utcNow(),
                        'failed' => true, 'last_failure' => DateTimeFormat::utcNow()]);
@@ -568,13 +560,10 @@ class GServer
                // If the URL missmatches, then we mark the old entry as failure
                if (!Strings::compareLink($url, $original_url)) {
                        self::setFailureByUrl($original_url);
-                       if (!self::getID($url, true)) {
+                       if (!self::getID($url, true) && !Network::isUrlBlocked($url)) {
                                self::detect($url, $network, $only_nodeinfo);
                        }
                        return false;
-               } elseif (Network::isUrlBlocked($url)) {
-                       Logger::info('Server domain is blocked', ['url' => $url]);
-                       return false;
                }
 
                $valid_url = Network::isUrlValid($url);
@@ -592,7 +581,7 @@ class GServer
                                (((parse_url($url, PHP_URL_HOST) != parse_url($valid_url, PHP_URL_HOST)) || (parse_url($url, PHP_URL_PATH) != parse_url($valid_url, PHP_URL_PATH))) && empty(parse_url($valid_url, PHP_URL_PATH)))) {
                                Logger::debug('Found redirect. Mark old entry as failure', ['old' => $url, 'new' => $valid_url]);
                                self::setFailureByUrl($url);
-                               if (!self::getID($valid_url, true)) {
+                               if (!self::getID($valid_url, true) && !Network::isUrlBlocked($valid_url)) {
                                        self::detect($valid_url, $network, $only_nodeinfo);
                                }
                                return false;
@@ -606,7 +595,7 @@ class GServer
                                $valid_url = (string)Uri::fromParts($parts);
 
                                self::setFailureByUrl($url);
-                               if (!self::getID($valid_url, true)) {
+                               if (!self::getID($valid_url, true) && !Network::isUrlBlocked($valid_url)) {
                                        self::detect($valid_url, $network, $only_nodeinfo);
                                }
                                return false;
index 51f8b4b7676abcc09e0f7f60af9470fbb0b35445..4829b538cf18fcbb11fa477d08143e2cc8086705 100644 (file)
@@ -63,7 +63,7 @@ class UpdateServerPeers
                        }
 
                        ++$total;
-                       if (DBA::exists('gserver', ['nurl' => 'http://' . $peer])) {
+                       if (DBA::exists('gserver', ['nurl' => Strings::normaliseLink('http://' . $peer)])) {
                                // We already know this server
                                continue;
                        }