Stop using StringUtil::convertEncoding()
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 13 May 2022 08:52:17 +0000 (10:52 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 13 May 2022 08:52:17 +0000 (10:52 +0200)
wcfsetup/install/files/lib/action/PaypalCallbackAction.class.php
wcfsetup/install/files/lib/page/AbstractPage.class.php
wcfsetup/install/files/lib/system/bbcode/KeywordHighlighter.class.php
wcfsetup/install/files/lib/system/message/unfurl/UnfurlResponse.class.php
wcfsetup/install/files/lib/util/UserUtil.class.php

index 717b188c3b28a3a60649a0fea562fc075ffc6a01..ae17a63c89f74c0a56d3a7d7f366e1f402a2bcb1 100644 (file)
@@ -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']));
                 }
             }
 
index 6d0699acd4eaf0e89045d59bedddbba178d7b4d7..55a169a8c790c2537d697641a3001a7571692d8b 100644 (file)
@@ -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)
index ac37a4651a4b944cd30f971311caf02f60d5a30d..b7cdb936727746215a36eaa857caa56715203d3f 100644 (file)
@@ -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
index 2e8eb680ad767670c27e7932c2055aae83eacbd1..61caa21a2b20d86c0f9131ba27316a120c19ab44 100644 (file)
@@ -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.",
index 74b6704743bc9b9138fc8600b8985c767addcd25..a379a87426be9de8705edb3ee94f4bef83e1e764 100644 (file)
@@ -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);