Index: tests/t3lib/matchcondition/t3lib_matchcondition_frontendTest.php =================================================================== --- tests/t3lib/matchcondition/t3lib_matchcondition_frontendTest.php (Revision 10012) +++ tests/t3lib/matchcondition/t3lib_matchcondition_frontendTest.php (Arbeitskopie) @@ -137,6 +137,77 @@ } /** + * Tests whether a condition does match the iOS with the correct and more recent 'iOS' + * @test + */ + public function conditionDoesMatchIosWithCorrectSystemKey() { + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7W367a Safari/531.21.10'; + $result = $this->matchCondition->match('[system = iOS]'); + $this->assertTrue($result); + } + + /** + * Tests whether a condition does match the iOS with the old 'mac' + * @test + */ + public function conditionDoesMatchIosWithOldSystemKey() { + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7W367a Safari/531.21.10'; + $result = $this->matchCondition->match('[system = mac]'); + $this->assertTrue($result); + } + + /** + * Tests whether a condition does match Windows 2000 with the correct and more recent 'win2k' + * @test + */ + public function conditionDoesMatchWindows2kWithNewSystemKey() { + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; SV1)'; + $result = $this->matchCondition->match('[system = win2k]'); + $this->assertTrue($result); + } + + /** + * Tests whether a condition does match Windows 2000 with the old 'winNT' + * @test + */ + public function conditionDoesMatchWindows2kWithOldSystemKey() { + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; SV1)'; + $result = $this->matchCondition->match('[system = winNT]'); + $this->assertTrue($result); + } + + /** + * Tests whether a condition does match Windows NT with 'winNT' + * @test + */ + public function conditionDoesMatchWindowsNtWithSystemKey() { + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0)'; + $result = $this->matchCondition->match('[system = winNT]'); + $this->assertTrue($result); + } + + + /** + * Tests whether a condition does match Android with the correct and more recent 'android' + * @test + */ + public function conditionDoesMatchAndroidWithNewSystemKey() { + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Linux; U; Android 2.3; en-US; sdk Build/GRH55) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'; + $result = $this->matchCondition->match('[system = android]'); + $this->assertTrue($result); + } + + /** + * Tests whether a condition does match Android with the old 'linux' + * @test + */ + public function conditionDoesMatchAndroidWithOldSystemKey() { + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Linux; U; Android 2.3; en-US; sdk Build/GRH55) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'; + $result = $this->matchCondition->match('[system = linux]'); + $this->assertTrue($result); + } + + /** * Tests whether a device type condition matches a crawler. * @test */ Index: tests/t3lib/matchcondition/t3lib_matchcondition_backendTest.php =================================================================== --- tests/t3lib/matchcondition/t3lib_matchcondition_backendTest.php (Revision 10012) +++ tests/t3lib/matchcondition/t3lib_matchcondition_backendTest.php (Arbeitskopie) @@ -158,7 +158,79 @@ $this->assertFalse($result); } + /** + * Tests whether a condition does match the iOS with the correct and more recent 'iOS' + * @test + */ + public function conditionDoesMatchIosWithCorrectSystemKey() { + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7W367a Safari/531.21.10'; + $result = $this->matchCondition->match('[system = iOS]'); + $this->assertTrue($result); + } + + /** + * Tests whether a condition does match the iOS with the old 'mac' + * @test + */ + public function conditionDoesMatchIosWithOldSystemKey() { + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7W367a Safari/531.21.10'; + $result = $this->matchCondition->match('[system = mac]'); + $this->assertTrue($result); + } + + /** + * Tests whether a condition does match Windows 2000 with the correct and more recent 'win2k' + * @test + */ + public function conditionDoesMatchWindows2kWithNewSystemKey() { + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; SV1)'; + $result = $this->matchCondition->match('[system = win2k]'); + $this->assertTrue($result); + } + + /** + * Tests whether a condition does match Windows 2000 with the old 'winNT' + * @test + */ + public function conditionDoesMatchWindows2kWithOldSystemKey() { + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; SV1)'; + $result = $this->matchCondition->match('[system = winNT]'); + $this->assertTrue($result); + } + + /** + * Tests whether a condition does match Windows NT with 'winNT' + * @test + */ + public function conditionDoesMatchWindowsNtWithSystemKey() { + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0)'; + $result = $this->matchCondition->match('[system = winNT]'); + $this->assertTrue($result); + } + + + /** + * Tests whether a condition does match Android with the correct and more recent 'android' + * @test + */ + public function conditionDoesMatchAndroidWithNewSystemKey() { + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Linux; U; Android 2.3; en-US; sdk Build/GRH55) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'; + $result = $this->matchCondition->match('[system = android]'); + $this->assertTrue($result); + } + + /** + * Tests whether a condition does match Android with the old 'linux' + * @test + */ + public function conditionDoesMatchAndroidWithOldSystemKey() { + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Linux; U; Android 2.3; en-US; sdk Build/GRH55) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'; + $result = $this->matchCondition->match('[system = linux]'); + $this->assertTrue($result); + } + + /** * Tests whether a device type condition matches a crawler. * @test */ Index: tests/t3lib/utility/t3lib_utility_clientTest.php =================================================================== --- tests/t3lib/utility/t3lib_utility_clientTest.php (Revision 10012) +++ tests/t3lib/utility/t3lib_utility_clientTest.php (Arbeitskopie) @@ -201,5 +201,317 @@ $infoArray['all']['gecko'] ); } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows7() { + $userAgentString = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'win7', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsVista() { + $userAgentString = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'winVista', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsXp() { + $userAgentString = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'winXP', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2k() { + $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; SV1)'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'win2k', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2kServicePack1() { + $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.01; SV1)'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'win2k', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsNt() { + $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0)'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'winNT', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringContainingNtAsFallback() { + $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT)'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'winNT', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpad() { + $userAgentString = 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7W367a Safari/531.21.10'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'iOS', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIphone() { + $userAgentString = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'iOS', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpod() { + $userAgentString = 'Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Geckto) Version/3.0 Mobile/3A101a Safari/419.3'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'iOS', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfMacOsX() { + $userAgentString = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-us) AppleWebKit/534.15+ (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'mac', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfLinux() { + $userAgentString = 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'linux', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfSolaris() { + $userAgentString = 'Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.1.9) Gecko/20100525 Firefox/3.5.9'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'unix_sun', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfAndroid() { + $userAgentString = 'Mozilla/5.0 (Linux; U; Android 2.3; en-US; sdk Build/GRH55) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'android', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfOpenbsd() { + $userAgentString = 'Links (1.00pre20; OpenBSD 4.8 i386; 80x25)'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'unix_bsd', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfNetbsd() { + $userAgentString = 'Links (2.2; NetBSD 5.1 amd64; 80x25)'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'unix_bsd', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfFreebsd() { + $userAgentString = 'Mozilla/5.0 (X11; U; FreeBSD amd64; c) AppleWebKit/531.2+ (KHTML, like Gecko) Safari 531.2+ Epiphany/230.2'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'unix_bsd', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfChromeOs() { + $userAgentString = 'Mozilla/5.0 (X11; U; CrOS i686 9.10.0; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.253.0 Safari 532.5'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'chrome', + $infoArray['system'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfSafari() { + $userAgentString = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'safari', + $infoArray['browser'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfFirefox() { + $userAgentString = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b8) Gecko/20100101 Firefox/4.0b8'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'firefox', + $infoArray['browser'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfOpera() { + $userAgentString = 'Opera/9.80 (X11; FreeBSD 8.1-RELEASE amd64; U; en) Presto/2.2.15 Version/10.10'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'opera', + $infoArray['browser'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfMobileSafariOnAndroid() { + $userAgentString = 'Mozilla/5.0 (Linux; U; Android WildPuzzleROM v8.0.7 froyo 2.2; de-de; HTC Wildfire Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'safari', + $infoArray['browser'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfMobileSafariOnIphone() { + $userAgentString = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'safari', + $infoArray['browser'] + ); + } + + /** + * @test + */ + public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfKonqueror() { + $userAgentString = 'Mozilla/5.0 (compatible; Konqueror/4.4; FreeBSD) KHTML/4.4.5 (like Gecko)'; + $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); + + $this->assertSame( + 'konqueror', + $infoArray['browser'] + ); + } } ?> \ No newline at end of file Index: t3lib/utility/class.t3lib_utility_client.php =================================================================== --- t3lib/utility/class.t3lib_utility_client.php (Revision 10012) +++ t3lib/utility/class.t3lib_utility_client.php (Arbeitskopie) @@ -104,10 +104,24 @@ } // system + // Microsoft Documentation about Platform tokens: http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx $browserInfo['system'] = ''; + $browserInfo['all_systems'] = ''; if (strstr($userAgent, 'Win')) { // windows - if (strstr($userAgent, 'Win98') || strstr($userAgent, 'Windows 98')) { + if (strstr($userAgent, 'Windows NT 6.1')) { + $browserInfo['system'] = 'win7'; + $browserInfo['all_systems'][] = 'winNT'; + } elseif (strstr($userAgent, 'Windows NT 6.0')) { + $browserInfo['system'] = 'winVista'; + $browserInfo['all_systems'][] = 'winNT'; + } elseif (strstr($userAgent, 'Windows NT 5.1')) { + $browserInfo['system'] = 'winXP'; + $browserInfo['all_systems'][] = 'winNT'; + } elseif (strstr($userAgent, 'Windows NT 5.0')) { + $browserInfo['system'] = 'win2k'; + $browserInfo['all_systems'][] = 'winNT'; + } elseif (strstr($userAgent, 'Win98') || strstr($userAgent, 'Windows 98')) { $browserInfo['system'] = 'win98'; } elseif (strstr($userAgent, 'Win95') || strstr($userAgent, 'Windows 95')) { $browserInfo['system'] = 'win95'; @@ -117,16 +131,31 @@ $browserInfo['system'] = 'win311'; } } elseif (strstr($userAgent, 'Mac')) { - $browserInfo['system'] = 'mac'; + if (strstr($userAgent, 'iPad') || strstr($userAgent, 'iPhone') || strstr($userAgent, 'iPod')) { + $browserInfo['system'] = 'iOS'; + $browserInfo['all_systems'][] = 'mac'; + } else { + $browserInfo['system'] = 'mac'; + } // unixes } elseif (strstr($userAgent, 'Linux')) { - $browserInfo['system'] = 'linux'; + if (strstr($userAgent, 'Android')) { + $browserInfo['system'] = 'android'; + $browserInfo['all_systems'][] = 'linux'; + } else { + $browserInfo['system'] = 'linux'; + } + } elseif (strstr($userAgent, 'BSD')) { + $browserInfo['system'] = 'unix_bsd'; } elseif (strstr($userAgent, 'SGI') && strstr($userAgent, ' IRIX ')) { $browserInfo['system'] = 'unix_sgi'; } elseif (strstr($userAgent, ' SunOS ')) { $browserInfo['system'] = 'unix_sun'; } elseif (strstr($userAgent, ' HP-UX ')) { $browserInfo['system'] = 'unix_hp'; + } elseif (strstr($userAgent, 'CrOS')) { + $browserInfo['system'] = 'chrome'; + $browserInfo['all_systems'][] = 'linux'; } return $browserInfo; Index: t3lib/matchcondition/class.t3lib_matchcondition_abstract.php =================================================================== --- t3lib/matchcondition/class.t3lib_matchcondition_abstract.php (Revision 10012) +++ t3lib/matchcondition/class.t3lib_matchcondition_abstract.php (Arbeitskopie) @@ -257,8 +257,14 @@ break; case 'system': $values = t3lib_div::trimExplode(',', $value, TRUE); + // Take all identified systems into account, e.g. mac for iOS, Linux + // for android and Windows NT for Windows XP + $allSystems = $browserInfo['system']; + if (!empty($browserInfo['all_systems'])) { + $allSystems .= ' ' . implode(' ', $browserInfo['all_systems']); + } foreach ($values as $test) { - if (strpos(' ' . $browserInfo['system'], $test) == 1) { + if (stripos($allSystems, $test) !== FALSE) { return TRUE; } }