From: Robert Kaiser Date: Mon, 19 Jul 2010 12:05:29 +0000 (+0200) Subject: ensure detection of newer Gecko UAs works correctly X-Git-Url: https://git-public.kairo.at/?a=commitdiff_plain;h=5cfa45a410351c990c1247d3148b693f52a4e7a9;p=php-utility-classes.git ensure detection of newer Gecko UAs works correctly --- diff --git a/include/classes/useragent.php-class b/include/classes/useragent.php-class index b6f7ab7..d941b79 100755 --- a/include/classes/useragent.php-class +++ b/include/classes/useragent.php-class @@ -1036,22 +1036,27 @@ class userAgent { $this->uadata['lang'] = (strpos($regs[3],'chrome://')===false)?$regs[3]:null; $this->uadata['eng_version'] = $regs[4]; } - elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) { + elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) { $this->uadata['os'] = $regs[2]; $this->uadata['lang'] = null; $this->uadata['eng_version'] = $regs[3]; } - elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) { + elseif (preg_match('|Mozilla/5.0 \(([^;]+); ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) { + $this->uadata['os'] = $regs[2]; + $this->uadata['lang'] = (strpos($regs[3],'chrome://')===false)?$regs[3]:null; + $this->uadata['eng_version'] = $regs[4]; + } + elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) { $this->uadata['os'] = $regs[2]; $this->uadata['lang'] = $regs[3]; $this->uadata['eng_version'] = 'M'.$regs[4]; } - elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) { + elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) { $this->uadata['os'] = $regs[1]; $this->uadata['lang'] = $regs[2]; $this->uadata['eng_version'] = 'M'.$regs[3]; } - elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) { + elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) { $this->uadata['os'] = $regs[2]; $this->uadata['lang'] = $regs[3]; $this->uadata['eng_version'] = null; diff --git a/testbed/ua_list_raw.txt b/testbed/ua_list_raw.txt index 6208262..7808040 100755 --- a/testbed/ua_list_raw.txt +++ b/testbed/ua_list_raw.txt @@ -35,6 +35,7 @@ Mozilla/5.0 (X11; U; Linux i686; chrome://navigator/locale/navigator.properties; Mozilla/5.0 (Windows; Windows NT 5.1; en-US; rv:1.9.2a1pre) Gecko/20090402 Firefox/3.6a1pre Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.5) Gecko/20041217 Firefox/1.0.4 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a6pre) Gecko/20070702 Minefield/3.0a6pre +Mozilla/5.0 (Windows; Windows NT 6.1; rv:2.0b4pre) Gecko/20100707 Minefield/4.0b4pre Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.22pre) Gecko/20090415 BonEcho/2.0.0.22pre (.NET CLR 3.5.30729) Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.15pre) Gecko/2009090911 GranParadiso/3.0.15pre (.NET CLR 3.5.30729) Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.4pre) Gecko/20090923 Shiretoko/3.5.4pre @@ -47,6 +48,7 @@ Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.19) Gecko/20081209 Thunder Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.1.7) Gecko/20100111 Icedove/3.0.1 ThunderBrowse/3.2.8.1 Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8b2) Gecko/20050324 SeaMonkey/1.0a Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9a6pre) Gecko/20070628 Firefox/2.0.0.4 SeaMonkey/2.0a1pre PrivatelyFakedUA/0.0 +Mozilla/5.0 (X11; Linux i686; de; rv:2.0b2pre) Gecko/20100719 NOT Firefox/4.0b2pre SeaMonkey/2.1a3pre Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.0.1) Gecko/20021109 Chimera/0.6+ Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7b) Gecko/20040302 Camino/0.7+ Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en; rv:1.8.1.5) Gecko/20070614 Camino/1.6 (like Firefox/2.0.0.4)