From 31b4209346da079d2cde3da4c0e0e46ea953252a Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 30 Mar 2015 08:26:31 +0000 Subject: [PATCH] fix user-agent detection to correctly detect "Mozilla/5.0 (Linux; Android 4.3; LT30p Build/9.2.A.1.205) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.117 Mobile Safari/537.36" as Chrome --- phpgwapi/inc/class.html.inc.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index 31e26fc912..11770ad5b1 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -62,11 +62,19 @@ class html static function _init_static() { // should be Ok for all HTML 4 compatible browsers - $parts = null; + $parts = $all_parts = null; if(!preg_match('/compatible; ([a-z]+)[\/ ]+([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$parts)) { - preg_match_all('/([a-z]+)\/([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$parts,PREG_SET_ORDER); - $parts = $parts[2][1] == 'Chrome' ? $parts[2] : array_pop($parts); + preg_match_all('/([a-z]+)\/([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$all_parts,PREG_SET_ORDER); + $parts = array_pop($all_parts); + foreach($all_parts as $p) + { + if ($p[1] == 'Chrome') + { + $parts = $p; + break; + } + } } list(,self::$user_agent,self::$ua_version) = $parts; if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') self::$user_agent = 'opera';