Skip to content

Commit

Permalink
MDL-48685 core_useragent: Correct IE 5.0 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jan 27, 2015
1 parent 483bdb5 commit eeaf954
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
14 changes: 7 additions & 7 deletions lib/classes/useragent.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ protected function guess_device_type() {
}
}
if ($this->is_useragent_mobile()) {
$this->devicetype = 'mobile';
$this->devicetype = self::DEVICETYPE_MOBILE;
} else if ($this->is_useragent_tablet()) {
$this->devicetype = 'tablet';
} else if (substr($this->useragent, 0, 34) === 'Mozilla/4.0 (compatible; MSIE 6.0;') {
// Safe way to check for IE6 and not get false positives for some IE 7/8 users.
$this->devicetype = 'legacy';
$this->devicetype = self::DEVICETYPE_TABLET;
} else if (self::check_ie_version('0') && !self::check_ie_version('7.0')) {
// IE 6 and before are considered legacy.
$this->devicetype = self::DEVICETYPE_LEGACY;
} else {
$this->devicetype = self::DEVICETYPE_DEFAULT;
}
Expand Down Expand Up @@ -884,7 +884,7 @@ public static function supports_svg() {
if ($instance->useragent === false) {
// Can't be sure, just say no.
$instance->supportssvg = false;
} else if (self::is_ie() and !self::check_ie_version('9')) {
} else if (self::check_ie_version('0') and !self::check_ie_version('9')) {
// IE < 9 doesn't support SVG. Say no.
$instance->supportssvg = false;
} else if (self::is_ie() and !self::check_ie_version('10') and self::check_ie_compatibility_view()) {
Expand All @@ -911,7 +911,7 @@ public static function supports_svg() {
*/
public static function supports_json_contenttype() {
// Modern browsers other than IE correctly supports 'application/json' media type.
if (!self::is_ie()) {
if (!self::check_ie_version('0')) {
return true;
}

Expand Down
9 changes: 4 additions & 5 deletions lib/tests/useragent_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
class core_useragent_testcase extends basic_testcase {

public function user_agents_providers() {
// Note: When adding new entries to this list, please ensure that any new browser versions are added to the corresponding list.
// This ensures that regression tests are applied to all known user agents.
return array(
// Windows 98; Internet Explorer 5.0.
array(
Expand All @@ -48,8 +50,7 @@ public function user_agents_providers() {
),

// IE 5.0 is a legacy browser.
// TODO Why is this not legacy!?
//'devicetype' => 'legacy',
'devicetype' => 'legacy',

'supports_svg' => false,
'supports_json_contenttype' => false,
Expand All @@ -71,8 +72,7 @@ public function user_agents_providers() {
),

// IE 6.0 is a legacy browser.
// TODO Why is this not legacy!?
//'devicetype' => 'legacy',
'devicetype' => 'legacy',

'supports_svg' => false,
'supports_json_contenttype' => false,
Expand Down Expand Up @@ -160,7 +160,6 @@ public function user_agents_providers() {
'7.0' => true,
'8.0' => true,
),
'iecompatibility' => false,
'versionclasses' => array(
'ie',
'ie8',
Expand Down

0 comments on commit eeaf954

Please sign in to comment.