Skip to content

Commit daf7459

Browse files
committed
Added a test for the new Internet Explorer 11 user agent
1 parent 90f1752 commit daf7459

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/Browser/Browser.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,15 @@ private static function checkBrowser()
198198
// user agents used in some older versions of Opera
199199
// (2) WebTV is strapped onto Internet Explorer so we must
200200
// check for WebTV before IE
201-
// (3) (deprecated) Galeon is based on Firefox and needs to be
201+
// (3) Because of Internet Explorer 11 using
202+
// "Mozilla/5.0 ([...] Trident/7.0; rv:11.0) like Gecko"
203+
// as user agent, tests for IE must be run before any
204+
// tests checking for "Mozilla"
205+
// (4) (deprecated) Galeon is based on Firefox and needs to be
202206
// tested before Firefox is tested
203-
// (4) OmniWeb is based on Safari so OmniWeb check must occur
207+
// (5) OmniWeb is based on Safari so OmniWeb check must occur
204208
// before Safari
205-
// (5) Netscape 9+ is based on Firefox so Netscape checks
209+
// (6) Netscape 9+ is based on Firefox so Netscape checks
206210
// before FireFox are necessary
207211
self::checkBrowserWebTv() ||
208212
self::checkBrowserInternetExplorer() ||
@@ -291,7 +295,7 @@ private static function checkBrowserInternetExplorer()
291295
self::setVersion('1.5');
292296
}
293297
return true;
294-
} // Test for versions > 1.5
298+
} // Test for versions > 1.5 and < 11
295299
else if (stripos(self::getUserAgent(), 'msie') !== false && stripos(self::getUserAgent(), 'opera') === false) {
296300
// See if the browser is the odd MSN Explorer
297301
if (stripos(self::getUserAgent(), 'msnb') !== false) {
@@ -304,6 +308,17 @@ private static function checkBrowserInternetExplorer()
304308
self::setBrowser(self::IE);
305309
self::setVersion(str_replace(array('(', ')', ';'), '', $aresult[1]));
306310
return true;
311+
} // Test for versions >= 11
312+
else if (stripos(self::getUserAgent(), 'trident') !== false) {
313+
self::setBrowser(self::IE);
314+
315+
preg_match('/rv:(\d+\.\d+)/', self::getUserAgent(), $matches);
316+
if (isset($matches[1])) {
317+
self::setVersion($matches[1]);
318+
return true;
319+
} else {
320+
return false;
321+
}
307322
} // Test for Pocket IE
308323
else if (stripos(self::getUserAgent(), 'mspie') !== false || stripos(self::getUserAgent(), 'pocket') !== false) {
309324
$aresult = explode(' ', stristr(self::getUserAgent(), 'mspie'));

0 commit comments

Comments
 (0)