]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/ParseUrl.php
Merge branch '2019.01-rc' into bug/6334-escape-get-app
[friendica.git] / src / Util / ParseUrl.php
index 1188214200cdc7d7971f65737886b0591008530e..70c5279cc84a42ce9314a202375cb2f1382c6fd5 100644 (file)
@@ -14,8 +14,6 @@ use Friendica\Database\DBA;
 use Friendica\Object\Image;
 use Friendica\Util\Strings;
 
-require_once 'include/dba.php';
-
 /**
  * @brief Class with methods for extracting certain content from an url
  */
@@ -113,7 +111,7 @@ class ParseUrl
         */
        public static function getSiteinfo($url, $no_guessing = false, $do_oembed = true, $count = 1)
        {
-               $a = get_app();
+               $a = \get_app();
 
                $siteinfo = [];
 
@@ -184,11 +182,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);
                }