correct detection of presto in Opera's Firefox-spoofing UA
authorRobert Kaiser <kairo@kairo.at>
Mon, 2 Jul 2007 15:29:23 +0000 (17:29 +0200)
committerRobert Kaiser <kairo@kairo.at>
Mon, 2 Jul 2007 15:29:23 +0000 (17:29 +0200)
include/classes/useragent.php-class

index e71505a73c533c8e6a5693dbade5cc7370230597..eba3ed2a308a5c1a3329dce344edf70b18cb962e 100755 (executable)
@@ -16,7 +16,7 @@
  *
  * The Initial Developer of the Original Code is
  * KaiRo - Robert Kaiser.
- * Portions created by the Initial Developer are Copyright (C) 2003
+ * Portions created by the Initial Developer are Copyright (C) 2003-2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s): Robert Kaiser <kairo@kairo.at>
@@ -746,7 +746,7 @@ class userAgent {
     if (!isset($this->uadata['engine'])) {
       $this->uadata['engine'] = 'unknown';
       $this->uadata['geckodate'] = null;
-      if (preg_match('|Gecko/([0-9]+)|', $this->uastring, $regs)) {
+      if (preg_match('|Gecko/([0-9]+)|', $this->uastring, $regs) && (strpos($this->brand, 'Opera') === false)) {
         $this->uadata['engine'] = 'gecko';
         $this->uadata['geckodate'] = $regs[1];
       }
@@ -956,6 +956,12 @@ class userAgent {
           $this->uadata['os'] = $regs[1];
           $this->uadata['lang'] = $regs[2];
         }
+        // Opera 9 Firefox-spoofing
+        elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+); rv:([^\);]+)\) Gecko\/\d+ Firefox\/[0-9a-zA-Z\.+]+ Opera [^ ]+/i', $this->uastring, $regs)) {
+          $this->uadata['eng_version'] = $this->getVersion();
+          $this->uadata['os'] = $regs[1];
+          $this->uadata['lang'] = $regs[2];
+        }
       }
       elseif ($this->hasEngine('nscp')) {
         if (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(X11; [^;]+; ([^\)]+)\)/i', $this->uastring, $regs)) {