From 37c7a18d00402df8cdc4233fb3be73377220a5f4 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 4 Sep 2018 10:52:17 -0400 Subject: [PATCH] Replace latin-1 by latin1 in charset detection - Simplify conditional for charset conversion --- src/Util/ParseUrl.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 79d8d2897..062a809b6 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -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); }