Permalink
Browse files

MDL-42491 libraries: add exception for IE11 (and hopefully later vers…

…ions)
  • Loading branch information...
1 parent 4e47920 commit a6989aa6e93ead31d9bde98c85a847c2e6e88175 @deraadt deraadt committed Oct 23, 2013
Showing with 16 additions and 0 deletions.
  1. +3 −0 lib/classes/useragent.php
  2. +13 −0 lib/tests/useragent_test.php
View
3 lib/classes/useragent.php
@@ -499,6 +499,9 @@ public static function check_ie_version($version = null) {
// See: http://www.useragentstring.com/pages/Internet%20Explorer/.
if (preg_match("/MSIE ([0-9\.]+)/", $useragent, $match)) {
$browser = $match[1];
+ // See: http://msdn.microsoft.com/en-us/library/ie/bg182625%28v=vs.85%29.aspx for IE11+ useragent details.
+ } else if (preg_match("/Trident\/[0-9\.]+/", $useragent) && preg_match("/rv:([0-9\.]+)/", $useragent, $match)) {
+ $browser = $match[1];
} else {
return false;
}
View
13 lib/tests/useragent_test.php
@@ -64,6 +64,9 @@ class core_useragent_testcase extends basic_testcase {
'10.0i' => array(
'Windows 8' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; Trident/6.0; Touch; .NET4.0E; .NET4.0C; Tablet PC 2.0)'
),
+ '11.0' => array(
+ 'Windows 8.1' => 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0)'
+ ),
),
'Firefox' => array(
'1.0.6' => array(
@@ -258,6 +261,16 @@ public function test_check_browser_version() {
$this->assertTrue(core_useragent::check_ie_version('10'));
$this->assertFalse(core_useragent::check_ie_version('11'));
+ core_useragent::instance(true, $this->user_agents['MSIE']['11.0']['Windows 8.1']);
+ $this->assertTrue(core_useragent::is_ie());
+ $this->assertTrue(core_useragent::check_ie_version());
+ $this->assertTrue(core_useragent::check_ie_version(0));
+ $this->assertTrue(core_useragent::check_ie_version('5.0'));
+ $this->assertTrue(core_useragent::check_ie_version('9.0'));
+ $this->assertTrue(core_useragent::check_ie_version('10'));
+ $this->assertTrue(core_useragent::check_ie_version('11'));
+ $this->assertFalse(core_useragent::check_ie_version('12'));
+
core_useragent::instance(true, $this->user_agents['Firefox']['2.0']['Windows XP']);
$this->assertTrue(core_useragent::is_firefox());
$this->assertTrue(core_useragent::check_firefox_version());

0 comments on commit a6989aa

Please sign in to comment.