mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-43679 core: Handle Meridio user agents with MS Word
This commit is contained in:
parent
f63dec4bb2
commit
d2fdad7c6c
@ -818,11 +818,12 @@ class core_useragent {
|
||||
$useragent = self::get_user_agent_string();
|
||||
if (!preg_match('/(\bWord\b|ms-office|MSOffice|Microsoft Office)/i', $useragent)) {
|
||||
return false;
|
||||
}
|
||||
if (strpos($useragent, 'Outlook') !== false) {
|
||||
} else if (strpos($useragent, 'Outlook') !== false) {
|
||||
return false;
|
||||
} else if (strpos($useragent, 'Meridio') !== false) {
|
||||
return false;
|
||||
}
|
||||
// It's Office and not Outlook - so it's probably Word, but we can't really be sure in most cases.
|
||||
// It's Office, not Outlook and not Meridio - so it's probably Word, but we can't really be sure in most cases.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,9 @@ class core_useragent_testcase extends basic_testcase {
|
||||
'7.0' => array(
|
||||
'Windows XP SP2' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; YPC 3.0.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)'
|
||||
),
|
||||
'7.0b' => array(
|
||||
'Windows XP' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Meridio for Excel 5.0.251; Meridio for PowerPoint 5.0.251; Meridio for Word 5.0.251; Meridio Protocol; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)'
|
||||
),
|
||||
'8.0' => array(
|
||||
'Windows Vista' => 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648)'
|
||||
),
|
||||
@ -167,6 +170,11 @@ class core_useragent_testcase extends basic_testcase {
|
||||
'2010' => array(
|
||||
'Windows 7' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Microsoft Outlook 14.0.7113; ms-office; MSOffice 14)'
|
||||
)
|
||||
),
|
||||
'Meridio' => array(
|
||||
'5.0.251' => array(
|
||||
'Windows XP' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Meridio for Excel 5.0.251; Meridio for PowerPoint 5.0.251; Meridio for Word 5.0.251; Meridio Protocol; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@ -274,6 +282,22 @@ class core_useragent_testcase extends basic_testcase {
|
||||
$this->assertFalse(core_useragent::check_ie_version('7.0'));
|
||||
$this->assertFalse(core_useragent::is_msword());
|
||||
|
||||
core_useragent::instance(true, $this->user_agents['MSIE']['7.0']['Windows XP SP2']);
|
||||
$this->assertTrue(core_useragent::is_ie());
|
||||
$this->assertTrue(core_useragent::check_ie_version());
|
||||
$this->assertTrue(core_useragent::check_ie_version('7.0'));
|
||||
$this->assertFalse(core_useragent::check_ie_compatibility_view());
|
||||
$this->assertFalse(core_useragent::check_ie_version('8.0'));
|
||||
$this->assertFalse(core_useragent::is_msword());
|
||||
|
||||
core_useragent::instance(true, $this->user_agents['MSIE']['7.0b']['Windows XP']);
|
||||
$this->assertTrue(core_useragent::is_ie());
|
||||
$this->assertTrue(core_useragent::check_ie_version());
|
||||
$this->assertTrue(core_useragent::check_ie_version('7.0'));
|
||||
$this->assertFalse(core_useragent::check_ie_compatibility_view());
|
||||
$this->assertFalse(core_useragent::check_ie_version('8.0'));
|
||||
$this->assertFalse(core_useragent::is_msword());
|
||||
|
||||
core_useragent::instance(true, $this->user_agents['MSIE']['9.0']['Windows 7']);
|
||||
$this->assertTrue(core_useragent::is_ie());
|
||||
$this->assertTrue(core_useragent::check_ie_version());
|
||||
@ -478,6 +502,10 @@ class core_useragent_testcase extends basic_testcase {
|
||||
// Outlook should not be considered to be MS Word.
|
||||
core_useragent::instance(true, $this->user_agents['MS Outlook']['2010']['Windows 7']);
|
||||
$this->assertFalse(core_useragent::is_msword());
|
||||
|
||||
// Meridio should not be considered to be MS Word.
|
||||
core_useragent::instance(true, $this->user_agents['Meridio']['5.0.251']['Windows XP']);
|
||||
$this->assertFalse(core_useragent::is_msword());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user