]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/ParseUrl.php
Replace deprecated Addon::callHooks with Hook::callAll
[friendica.git] / src / Util / ParseUrl.php
index 79d8d2897e870cfcd5e7a779050ee6357bc26b93..cdafc7387b800b7b8019ffc394981066aef38ac9 100644 (file)
@@ -8,11 +8,10 @@ namespace Friendica\Util;
 use DOMDocument;
 use DOMXPath;
 use Friendica\Content\OEmbed;
-use Friendica\Core\Addon;
+use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Database\DBA;
 use Friendica\Object\Image;
-use Friendica\Util\Strings;
 
 /**
  * @brief Class with methods for extracting certain content from an url
@@ -111,7 +110,7 @@ class ParseUrl
         */
        public static function getSiteinfo($url, $no_guessing = false, $do_oembed = true, $count = 1)
        {
-               $a = get_app();
+               $a = \get_app();
 
                $siteinfo = [];
 
@@ -182,11 +181,10 @@ class ParseUrl
                        $charset = trim(trim(trim(array_pop($matches)), ';,'));
                }
 
-               if ($charset == '') {
-                       $charset = 'utf-8';
-               }
+               if ($charset && strtoupper($charset) != 'UTF-8') {
+                       // See https://github.com/friendica/friendica/issues/5470#issuecomment-418351211
+                       $charset = str_ireplace('latin-1', 'latin1', $charset);
 
-               if (($charset != '') && (strtoupper($charset) != 'UTF-8')) {
                        Logger::log('detected charset ' . $charset, Logger::DEBUG);
                        $body = iconv($charset, 'UTF-8//TRANSLIT', $body);
                }
@@ -423,7 +421,7 @@ class ParseUrl
 
                Logger::log('Siteinfo for ' . $url . ' ' . print_r($siteinfo, true), Logger::DEBUG);
 
-               Addon::callHooks('getsiteinfo', $siteinfo);
+               Hook::callAll('getsiteinfo', $siteinfo);
 
                return $siteinfo;
        }