]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/Proxy.php
spelling: occurred
[friendica.git] / src / Util / Proxy.php
index fc7d369ad528d1b4d89f9e9c76aeb6d5c034dfb6..7f3c94672273dacb5341e6d98d6ef4080fd73c4e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -24,6 +24,7 @@ namespace Friendica\Util;
 use Friendica\Core\Logger;
 use Friendica\Core\System;
 use Friendica\DI;
+use GuzzleHttp\Psr7\Uri;
 
 /**
  * Proxy utilities class
@@ -140,7 +141,7 @@ class Proxy
        {
                $html = str_replace(Strings::normaliseLink(DI::baseUrl()) . '/', DI::baseUrl() . '/', $html);
 
-               return preg_replace_callback('/(<img [^>]*src *= *["\'])([^"\']+)(["\'][^>]*>)/siU', 'self::replaceUrl', $html);
+               return preg_replace_callback('/(<img [^>]*src *= *["\'])([^"\']+)(["\'][^>]*>)/siU', [self::class, 'replaceUrl'], $html);
        }
 
        /**
@@ -173,12 +174,15 @@ class Proxy
         */
        private static function parseQuery(string $url): array
        {
-               $query = parse_url($url, PHP_URL_QUERY);
-               $query = html_entity_decode($query);
+               try {
+                       $uri = new Uri($url);
 
-               parse_str($query, $arr);
+                       parse_str($uri->getQuery(), $arr);
 
-               return $arr;
+                       return $arr;
+               } catch (\Throwable $e) {
+                       return [];
+               }
        }
 
        /**