[BUGFIX] ClientUtility does not detect Internet Explorer 11
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Utility / ClientUtility.php
index ae64bf6..47cf95f 100644 (file)
@@ -89,9 +89,21 @@ class ClientUtility {
                $pattern = '#(?P<browser>' . join('|', $known) . ')[/ ]+(?P<version>[0-9]+(?:\\.[0-9]+)?)#';
                // Find all phrases (or return empty array if none found)
                if (!preg_match_all($pattern, strtolower($userAgent), $matches)) {
-                       $browserInfo['browser'] = 'unknown';
-                       $browserInfo['version'] = '';
-                       $browserInfo['all'] = array();
+                       // Microsoft Internet-Explorer 11 does not have a sign of "MSIE" or so in the useragent.
+                       // All checks from the pattern above fail here. Look for a special combination of
+                       // "Mozilla/5.0" in front, "Trident/7.0" in the middle and "like Gecko" at the end.
+                       // The version (revision) is given as "; rv:11.0" in the useragent then.
+                       unset($matches);
+                       $pattern = '#mozilla/5\\.0 \\(.*trident/7\\.0.*; rv:(?P<version>[0-9]+(?:\\.[0-9]+)?)\\) like gecko#i';
+                       if (preg_match_all($pattern, $userAgent, $matches)) {
+                               $browserInfo['browser'] = 'msie';
+                               $browserInfo['version'] = $matches['version'][0];
+                               $browserInfo['all'] = array('msie' => $matches['version'][0]);
+                       } else {
+                               $browserInfo['browser'] = 'unknown';
+                               $browserInfo['version'] = '';
+                               $browserInfo['all'] = array();
+                       }
                } else {
                        // Since some UAs have more than one phrase (e.g Firefox has a Gecko phrase,
                        // Opera 7,8 have a MSIE phrase), use the last one found (the right-most one
@@ -101,6 +113,7 @@ class ClientUtility {
                        $browserInfo['browser'] = $matches['browser'][$lastIndex];
                        $browserInfo['version'] = $browserInfo['browser'] === 'msie' ? $matches['version'][0] : $matches['version'][$lastIndex];
                        // But return all parsed browsers / version in an extra array
+                       $browserInfo['all'] = array();
                        for ($i = 0; $i <= $lastIndex; $i++) {
                                if (!isset($browserInfo['all'][$matches['browser'][$i]])) {
                                        $browserInfo['all'][$matches['browser'][$i]] = $matches['version'][$i];