From: Marcel Werk Date: Fri, 21 Feb 2014 00:03:01 +0000 (+0100) Subject: Fixed encoding issue X-Git-Tag: 2.0.3~26 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bc56f6199cdcf243d1220d8ab565b2cfa2d1d6ed;p=GitHub%2FWoltLab%2FWCF.git Fixed encoding issue --- diff --git a/wcfsetup/install/files/lib/util/UserUtil.class.php b/wcfsetup/install/files/lib/util/UserUtil.class.php index 34d2da8f47..e385ca5cfb 100644 --- a/wcfsetup/install/files/lib/util/UserUtil.class.php +++ b/wcfsetup/install/files/lib/util/UserUtil.class.php @@ -100,7 +100,14 @@ final class UserUtil { * @return string */ public static function getUserAgent() { - if (isset($_SERVER['HTTP_USER_AGENT'])) return substr($_SERVER['HTTP_USER_AGENT'], 0, 255); + if (isset($_SERVER['HTTP_USER_AGENT'])) { + $userAgent = $_SERVER['HTTP_USER_AGENT']; + if (!StringUtil::isASCII($userAgent) && !StringUtil::isUTF8($userAgent)) { + $userAgent = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $userAgent); + } + + return mb_substr($userAgent, 0, 255); + } return ''; }