Fixed encoding issue
authorMarcel Werk <burntime@woltlab.com>
Fri, 21 Feb 2014 00:03:01 +0000 (01:03 +0100)
committerMarcel Werk <burntime@woltlab.com>
Fri, 21 Feb 2014 00:03:01 +0000 (01:03 +0100)
wcfsetup/install/files/lib/util/UserUtil.class.php

index 34d2da8f47e3fd6411733da1bd3a9d373de96bba..e385ca5cfb4fe99f67ed8ab85603e8a2413998cd 100644 (file)
@@ -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 '';
        }