]> git.mxchange.org Git - friendica.git/commitdiff
Replace latin-1 by latin1 in charset detection
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 4 Sep 2018 14:52:17 +0000 (10:52 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 29 Dec 2018 05:43:00 +0000 (00:43 -0500)
- Simplify conditional for charset conversion

src/Util/ParseUrl.php

index 79d8d2897e870cfcd5e7a779050ee6357bc26b93..062a809b6a9d74c7a6c52ba1676b11bec9d5eafb 100644 (file)
@@ -182,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);
                }