From 523c035707cdadf68edda786d55dca3dad560d5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 13 May 2022 10:52:17 +0200 Subject: [PATCH] Stop using StringUtil::convertEncoding() --- .../install/files/lib/action/PaypalCallbackAction.class.php | 3 +-- wcfsetup/install/files/lib/page/AbstractPage.class.php | 2 +- .../files/lib/system/bbcode/KeywordHighlighter.class.php | 2 +- .../files/lib/system/message/unfurl/UnfurlResponse.class.php | 2 +- wcfsetup/install/files/lib/util/UserUtil.class.php | 4 ++-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/lib/action/PaypalCallbackAction.class.php b/wcfsetup/install/files/lib/action/PaypalCallbackAction.class.php index 717b188c3b..ae17a63c89 100644 --- a/wcfsetup/install/files/lib/action/PaypalCallbackAction.class.php +++ b/wcfsetup/install/files/lib/action/PaypalCallbackAction.class.php @@ -8,7 +8,6 @@ use Psr\Http\Client\ClientExceptionInterface; use wcf\data\object\type\ObjectTypeCache; use wcf\system\io\HttpFactory; use wcf\system\payment\type\IPaymentType; -use wcf\util\StringUtil; /** * Handles Paypal callbacks. @@ -69,7 +68,7 @@ class PaypalCallbackAction extends AbstractAction // fix encoding if (!empty($_POST['charset']) && \strtoupper($_POST['charset']) != 'UTF-8') { foreach ($_POST as &$value) { - $value = StringUtil::convertEncoding(\strtoupper($_POST['charset']), 'UTF-8', $value); + $value = \mb_convert_encoding($value, 'UTF-8', \strtoupper($_POST['charset'])); } } diff --git a/wcfsetup/install/files/lib/page/AbstractPage.class.php b/wcfsetup/install/files/lib/page/AbstractPage.class.php index 6d0699acd4..55a169a8c7 100644 --- a/wcfsetup/install/files/lib/page/AbstractPage.class.php +++ b/wcfsetup/install/files/lib/page/AbstractPage.class.php @@ -276,7 +276,7 @@ abstract class AbstractPage implements IPage $requestURI = (!empty($_SERVER['UNENCODED_URL'])) ? $_SERVER['UNENCODED_URL'] : $_SERVER['REQUEST_URI']; if (!StringUtil::isUTF8($requestURI)) { - $requestURI = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $requestURI); + $requestURI = \mb_convert_encoding($requestURI, 'UTF-8', 'ISO-8859-1'); } // some webservers output lower-case encoding (e.g. %c3 instead of %C3) diff --git a/wcfsetup/install/files/lib/system/bbcode/KeywordHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/KeywordHighlighter.class.php index ac37a4651a..b7cdb93672 100644 --- a/wcfsetup/install/files/lib/system/bbcode/KeywordHighlighter.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/KeywordHighlighter.class.php @@ -101,7 +101,7 @@ class KeywordHighlighter extends SingletonFactory { // convert encoding if necessary if (!StringUtil::isUTF8($keywordString)) { - $keywordString = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $keywordString); + $keywordString = \mb_convert_encoding($keywordString, 'UTF-8', 'ISO-8859-1'); } // remove bad wildcards diff --git a/wcfsetup/install/files/lib/system/message/unfurl/UnfurlResponse.class.php b/wcfsetup/install/files/lib/system/message/unfurl/UnfurlResponse.class.php index 2e8eb680ad..61caa21a2b 100644 --- a/wcfsetup/install/files/lib/system/message/unfurl/UnfurlResponse.class.php +++ b/wcfsetup/install/files/lib/system/message/unfurl/UnfurlResponse.class.php @@ -153,7 +153,7 @@ final class UnfurlResponse if ($this->responseCharset !== 'UTF-8') { try { - $this->body = StringUtil::convertEncoding($this->responseCharset, 'UTF-8', $this->body); + $this->body = \mb_convert_encoding($this->body, 'UTF-8', $this->responseCharset); } catch (Exception | ValueError $e) { throw new ParsingFailed( "Could not parse body, due an invalid charset.", diff --git a/wcfsetup/install/files/lib/util/UserUtil.class.php b/wcfsetup/install/files/lib/util/UserUtil.class.php index 74b6704743..a379a87426 100644 --- a/wcfsetup/install/files/lib/util/UserUtil.class.php +++ b/wcfsetup/install/files/lib/util/UserUtil.class.php @@ -106,7 +106,7 @@ final class UserUtil if (isset($_SERVER['HTTP_USER_AGENT'])) { $userAgent = $_SERVER['HTTP_USER_AGENT']; if (!StringUtil::isUTF8($userAgent)) { - $userAgent = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $userAgent); + $userAgent = \mb_convert_encoding($userAgent, 'UTF-8', 'ISO-8859-1'); } return \mb_substr($userAgent, 0, 191); @@ -247,7 +247,7 @@ final class UserUtil // fix encoding if (!StringUtil::isUTF8($REQUEST_URI)) { - $REQUEST_URI = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $REQUEST_URI); + $REQUEST_URI = \mb_convert_encoding($REQUEST_URI, 'UTF-8', 'ISO-8859-1'); } return \mb_substr(FileUtil::unifyDirSeparator($REQUEST_URI), 0, 255); -- 2.20.1