]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/Network.php
Replace deprecated Addon::callHooks with Hook::callAll
[friendica.git] / src / Util / Network.php
index e7707baf38a8182af47c77e287b40bc281c8d8c1..5cac96b79cdd0afb0beab0576378e49c6fe0edbe 100644 (file)
@@ -4,12 +4,11 @@
  */
 namespace Friendica\Util;
 
-use Friendica\Core\Addon;
+use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\System;
 use Friendica\Core\Config;
 use Friendica\Network\CurlResult;
-use Friendica\Util\Strings;
 use DOMDocument;
 use DomXPath;
 
@@ -94,7 +93,12 @@ class Network
 
                $stamp1 = microtime(true);
 
-               $a = get_app();
+               $a = \get_app();
+
+               if (strlen($url) > 1000) {
+                       Logger::log('URL is longer than 1000 characters. Callstack: ' . System::callstack(20), Logger::DEBUG);
+                       return CurlResult::createErrorCurl(substr($url, 0, 200));
+               }
 
                $parts = parse_url($url);
                $path_parts = explode('/', defaults($parts, 'path', ''));
@@ -251,7 +255,7 @@ class Network
                        return CurlResult::createErrorCurl($url);
                }
 
-               $a = get_app();
+               $a = \get_app();
                $ch = curl_init($url);
 
                if (($redirects > 8) || (!$ch)) {
@@ -362,7 +366,7 @@ class Network
                /// @TODO Really suppress function outcomes? Why not find them + debug them?
                $h = @parse_url($url);
 
-               if ((is_array($h)) && (@dns_get_record($h['host'], DNS_A + DNS_CNAME) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
+               if (!empty($h['host']) && (@dns_get_record($h['host'], DNS_A + DNS_CNAME) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
                        return $url;
                }
 
@@ -528,7 +532,7 @@ class Network
                $avatar['url'] = '';
                $avatar['success'] = false;
 
-               Addon::callHooks('avatar_lookup', $avatar);
+               Hook::callAll('avatar_lookup', $avatar);
 
                if (! $avatar['success']) {
                        $avatar['url'] = System::baseUrl() . '/images/person-300.jpg';
@@ -604,7 +608,7 @@ class Network
         */
        public static function finalUrl($url, $depth = 1, $fetchbody = false)
        {
-               $a = get_app();
+               $a = \get_app();
 
                $url = self::stripTrackingQueryParams($url);