From 1c7afa4e2885822c1943ca0d93cddc3317abf20d Mon Sep 17 00:00:00 2001
From: sgiehl <stefan@piwik.org>
Date: Thu, 20 Feb 2014 10:24:46 +0100
Subject: [PATCH] added detection for Sabayon Linux; fixed detections; added
 tests

---
 .../UserAgentParserEnhanced.php               |   3 +-
 .../UserAgentParserEnhanced/regexes/oss.yml   |   9 +-
 .../userAgentParserEnhancedFixtures.yml       | 130 +++++++++++++++++-
 3 files changed, 138 insertions(+), 4 deletions(-)

diff --git a/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php b/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php
index 3da3dec1f3..32aff13d47 100644
--- a/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php
+++ b/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php
@@ -222,6 +222,7 @@ class UserAgentParserEnhanced
         'Puppy'                => 'PPY',
         'Red Hat'              => 'RHT',
         'RISC OS'              => 'ROS',
+        'Sabayon'              => 'SAB',
         'SUSE'                 => 'SSE',
         'Sailfish OS'          => 'SAF',
         'Slackware'            => 'SLW',
@@ -276,7 +277,7 @@ class UserAgentParserEnhanced
         'IBM'                   => array('OS2'),
         'iOS'                   => array('IOS'),
         'RISC OS'               => array('ROS'),
-        'Linux'                 => array('LIN', 'ARL', 'DEB', 'KNO', 'MIN', 'UBT', 'KBT', 'XBT', 'LBT', 'FED', 'RHT', 'MDR', 'GNT', 'SLW', 'SSE', 'PPY', 'CES', 'BTR', 'YNS', 'PRS', 'SAF'),
+        'Linux'                 => array('LIN', 'ARL', 'DEB', 'KNO', 'MIN', 'UBT', 'KBT', 'XBT', 'LBT', 'FED', 'RHT', 'MDR', 'GNT', 'SAB', 'SLW', 'SSE', 'PPY', 'CES', 'BTR', 'YNS', 'PRS', 'SAF'),
         'Mac'                   => array('MAC'),
         'Mobile Gaming Console' => array('PSP', 'NDS', 'XBX'),
         'Other Mobile'          => array('WOS', 'POS', 'QNX', 'SBA', 'TIZ', 'SMG'),
diff --git a/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/oss.yml b/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/oss.yml
index b76b32761e..7db95595a3 100644
--- a/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/oss.yml
+++ b/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/oss.yml
@@ -72,14 +72,19 @@
 ##########
 # Linux
 ##########
-- regex: 'Linux; .*((?:Arch Linux|Debian|Knoppix|Mint|Ubuntu|Kubuntu|Xubuntu|Lubuntu|Fedora|Red Hat|Mandriva|Gentoo|Slackware|SUSE|Puppy|CentOS|BackTrack|YunOs|Presto))[ /](\d+\.\d+)'
+- regex: 'Linux; .*((?:Arch Linux|Debian|Knoppix|Mint|Ubuntu|Kubuntu|Xubuntu|Lubuntu|Fedora|Red Hat|Mandriva|Gentoo|Sabayon|Slackware|SUSE|Puppy|CentOS|BackTrack|YunOs|Presto))[ /](\d+\.\d+)'
   name: '$1'
   version: '$2'
   
   
-- regex: '(Arch Linux|Debian|Knoppix|Mint|Ubuntu|Kubuntu|Xubuntu|Lubuntu|Fedora|Red Hat|Mandriva|Gentoo|Slackware|SUSE|Puppy|CentOS|BackTrack|YunOs)(?: Linux)?(?:[ /\-](\d+\.\d+))?'
+- regex: '(Arch Linux|Debian|Knoppix|Mint|Ubuntu|Kubuntu|Xubuntu|Lubuntu|Fedora|Red Hat|Mandriva|Gentoo|Sabayon|Slackware|SUSE|Puppy|CentOS|BackTrack|YunOs)(?: Linux)?(?:[ /\-](\d+\.\d+))?'
   name: '$1'
   version: '$2'
+
+
+- regex: 'ArchLinux(?:[ /\-](\d+\.\d+))?'
+  name: 'Arch Linux'
+  version: '$1'
   
 # generic linux match -> end of file
 
diff --git a/tests/PHPUnit/Fixtures/userAgentParserEnhancedFixtures.yml b/tests/PHPUnit/Fixtures/userAgentParserEnhancedFixtures.yml
index 3655e1dba3..6b2b1f0885 100644
--- a/tests/PHPUnit/Fixtures/userAgentParserEnhancedFixtures.yml
+++ b/tests/PHPUnit/Fixtures/userAgentParserEnhancedFixtures.yml
@@ -18030,4 +18030,132 @@
     brand: 
     model: 
   os_family: Linux
-  browser_family: Unknown
\ No newline at end of file
+  browser_family: Unknown
+-
+  user_agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 CentOS/3.6-2.el5.centos Firefox/3.6.13
+  os:
+    name: CentOS
+    short_name: CES
+    version: 3.6
+  browser:
+    name: Firefox
+    short_name: FF
+    version: 3.6
+  device:
+    type: desktop
+    brand: 
+    model: 
+  os_family: Linux
+  browser_family: Firefox
+-
+  user_agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.24) Gecko/20111101 SUSE/3.6.24-0.2.1 Firefox/3.6.24
+  os:
+    name: SUSE
+    short_name: SSE
+    version: 3.6
+  browser:
+    name: Firefox
+    short_name: FF
+    version: 3.6
+  device:
+    type: desktop
+    brand: 
+    model: 
+  os_family: Linux
+  browser_family: Firefox
+-
+  user_agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a3pre) Gecko/20070301 Minefield/3.0a3pre
+  os:
+    name: Linux
+    short_name: LIN
+    version: 
+  browser:
+    name: Firefox
+    short_name: FF
+    version: Minefield (3.0)
+  device:
+    type: desktop
+    brand: 
+    model: 
+  os_family: Linux
+  browser_family: Firefox
+-
+  user_agent: Mozilla/5.0 (X11; U; Linux i686; fr-fr) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/531.2+ Debian/squeeze (2.30.6-1) Epiphany/2.30.6
+  os:
+    name: Debian
+    short_name: DEB
+    version: 
+  browser:
+    name: Epiphany
+    short_name: EP
+    version: 2.30
+  device:
+    type: desktop
+    brand: 
+    model: 
+  os_family: Linux
+  browser_family: Unknown
+-
+  user_agent: Mozilla/5.0 ArchLinux (X11; U; Linux x86_64; en-US) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.100 Safari/534.30
+  os:
+    name: Arch Linux
+    short_name: ARL
+    version: 
+  browser:
+    name: Chrome
+    short_name: CH
+    version: 12.0
+  device:
+    type: desktop
+    brand: 
+    model: 
+  os_family: Linux
+  browser_family: Chrome
+-
+  user_agent: Opera/9.80 (X11; Linux x86_64; Sabayon) Presto/2.12.388 Version/12.16
+  os:
+    name: Sabayon
+    short_name: SAB
+    version: 
+  browser:
+    name: Opera
+    short_name: OP
+    version: 12.16
+  device:
+    type: desktop
+    brand: 
+    model: 
+  os_family: Linux
+  browser_family: Opera
+-
+  user_agent: UCWEB/2.0 (Linux; U; Opera Mini/7.1.32052/30.3697; en-US; LG-E405) U2/1.0.0 UCBrowser/8.8.1.359 Mobile
+  os:
+    name: Linux
+    short_name: LIN
+    version: 
+  browser:
+    name: Opera Mini
+    short_name: OI
+    version: 7.1
+  device:
+    type: smartphone
+    brand: LG
+    model: E405
+  os_family: Linux
+  browser_family: Opera
+-
+  user_agent: ZTE U930_TD/1.0 Linux/2.6.39 Android/4.0 Release/3.5.2012 Browser/AppleWebKit534.30
+  os:
+    name: Android
+    short_name: AND
+    version: 4.0
+  browser:
+    name: Android Browser
+    short_name: AN
+    version: 
+  device:
+    type: smartphone
+    brand: ZT
+    model: U930
+  os_family: Android
+  browser_family: Android Browser
\ No newline at end of file
-- 
GitLab