Permalink
Browse files

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

…ions)
  • Loading branch information...
1 parent b6ced2f commit c58f3ed7ff021fbf833f0e8152c51e5f341541c9 @deraadt deraadt committed Oct 25, 2013
Showing with 13 additions and 0 deletions.
  1. +3 −0 lib/moodlelib.php
  2. +10 −0 lib/tests/moodlelib_test.php
View
3 lib/moodlelib.php
@@ -8603,6 +8603,9 @@ function check_browser_version($brand, $version = null) {
// See: http://www.useragentstring.com/pages/Internet%20Explorer/
if (preg_match("/MSIE ([0-9\.]+)/", $agent, $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\.]+/", $agent) && preg_match("/rv:([0-9\.]+)/", $agent, $match)) {
+ $browser = $match[1];
} else {
return false;
}
View
10 lib/tests/moodlelib_test.php
@@ -45,6 +45,7 @@ class moodlelib_testcase extends advanced_testcase {
'9.0i' => array('Windows 7' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)'),
'10.0' => array('Windows 8' => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch)'),
'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('Windows XP' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6'),
@@ -301,6 +302,15 @@ function test_check_browser_version()
$this->assertTrue(check_browser_version('MSIE', '10'));
$this->assertFalse(check_browser_version('MSIE', '11'));
+ $_SERVER['HTTP_USER_AGENT'] = $this->user_agents['MSIE']['11.0']['Windows 8.1'];
+ $this->assertTrue(check_browser_version('MSIE'));
+ $this->assertTrue(check_browser_version('MSIE', 0));
+ $this->assertTrue(check_browser_version('MSIE', '5.0'));
+ $this->assertTrue(check_browser_version('MSIE', '9.0'));
+ $this->assertTrue(check_browser_version('MSIE', '10'));
+ $this->assertTrue(check_browser_version('MSIE', '11'));
+ $this->assertFalse(check_browser_version('MSIE', '12'));
+
$_SERVER['HTTP_USER_AGENT'] = $this->user_agents['Firefox']['2.0']['Windows XP'];
$this->assertTrue(check_browser_version('Firefox'));
$this->assertTrue(check_browser_version('Firefox', '1.5'));

0 comments on commit c58f3ed

Please sign in to comment.