Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds detection for Raspberry Pi OS, Raspbian, UOS operating systems, Raspbian Chromium browser, SPARC64 platform and improves version detection for OS/2, PICO OS #7590

Merged
merged 14 commits into from
Feb 19, 2024
Merged
3 changes: 2 additions & 1 deletion Parser/Client/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ class Browser extends AbstractClientParser
'QZ' => 'QupZilla',
'QM' => 'Qwant Mobile',
'QW' => 'QtWebEngine',
'R2' => 'Raspbian Chromium',
'RE' => 'Realme Browser',
'RK' => 'Rekonq',
'RM' => 'RockMelt',
Expand Down Expand Up @@ -642,7 +643,7 @@ class Browser extends AbstractClientParser
'1W', 'EV', 'I9', 'V4', 'H4', '1T', 'M5', '0S', '0C',
'ZR', 'D6', 'F6', 'RC', 'WD', 'P3', 'FT', 'A9', 'X2',
'N3', 'GD', 'O9', 'Q3', 'F7', 'K2', 'P5', 'H5', 'V3',
'K3', 'Q4', 'G2',
'K3', 'Q4', 'G2', 'R2',
],
'Firefox' => [
'AX', 'BI', 'BF', 'BH', 'BN', 'C0', 'CU', 'EI', 'F1',
Expand Down
18 changes: 17 additions & 1 deletion Parser/OperatingSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class OperatingSystem extends AbstractParser
'PSP' => 'PlayStation Portable',
'PS3' => 'PlayStation',
'PUR' => 'PureOS',
'PIO' => 'Raspberry Pi OS',
'RAS' => 'Raspbian',
'RHT' => 'Red Hat',
'RED' => 'RedOS',
'REV' => 'Revenge OS',
Expand Down Expand Up @@ -161,6 +163,7 @@ class OperatingSystem extends AbstractParser
'TIV' => 'TiVo OS',
'TOS' => 'TmaxOS',
'UBT' => 'Ubuntu',
'UOS' => 'UOS',
'VID' => 'VIDAA',
'WAS' => 'watchOS',
'WER' => 'Wear OS',
Expand Down Expand Up @@ -209,7 +212,8 @@ class OperatingSystem extends AbstractParser
'ORD', 'TOS', 'RSO', 'DEE', 'FRE', 'MAG', 'FEN', 'CAI', 'PCL', 'HAS',
'LOS', 'DVK', 'ROK', 'OWR', 'OTV', 'KTV', 'PUR', 'PLA', 'FUC', 'PAR',
'FOR', 'MON', 'KAN', 'ZEN', 'LND', 'LNS', 'CHN', 'AMZ', 'TEN', 'CST',
'NOV', 'ROU', 'ZOR', 'RED', 'KAL', 'ORA', 'VID', 'TIV', 'BSN',
'NOV', 'ROU', 'ZOR', 'RED', 'KAL', 'ORA', 'VID', 'TIV', 'BSN', 'RAS',
'UOS', 'PIO',
],
'Mac' => ['MAC'],
'Mobile Gaming Console' => ['PSP', 'NDS', 'XBX'],
Expand Down Expand Up @@ -315,6 +319,10 @@ public function parse(): ?array
$version = '';
}

if ('PICO OS' === $name) {
$version = $osFromUserAgent['version'];
}

if ('Fire OS' === $osFromUserAgent['name']) {
$majorVersion = (int) (\explode('.', $version, 1)[0] ?? '0');

Expand Down Expand Up @@ -564,6 +572,10 @@ protected function parsePlatform(): string
return 'SuperH';
}

if (false !== \strpos($arch, 'sparc64')) {
return 'SPARC64';
}

if (false !== \strpos($arch, 'x64')
|| (false !== \strpos($arch, 'x86') && '64' === $this->clientHints->getBitness())
) {
Expand All @@ -587,6 +599,10 @@ protected function parsePlatform(): string
return 'SuperH';
}

if ($this->matchUserAgent('sparc64')) {
return 'SPARC64';
}

if ($this->matchUserAgent('64-?bit|WOW64|(?:Intel)?x64|WINDOWS_64|win64|amd64|x86_?64')) {
return 'x64';
}
Expand Down
9 changes: 9 additions & 0 deletions Tests/Parser/Client/fixtures/browser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8187,6 +8187,15 @@
engine: WebKit
engine_version: ""
family:
-
user_agent: Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Raspbian Chromium/72.0.3626.121 Chrome/72.0.3626.121 Safari/537.36
client:
type: browser
name: Raspbian Chromium
version: 72.0.3626.121
engine: Blink
engine_version: 72.0.3626.121
family: Chrome
-
user_agent: 'Dalvik/2.1.0 (Linux; U; Android 13; SM-A245M Build/TP1A.220624.014) AppleWebKit [PB/171] (KHTML, like Gecko) Chrome/108.0.0.0 Mobile Safari/537.36'
client:
Expand Down
45 changes: 44 additions & 1 deletion Tests/Parser/fixtures/oss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
os:
name: OS/2
short_name: OS2
version:
version: "4.5"
platform:
family: IBM
-
Expand Down Expand Up @@ -4190,6 +4190,49 @@
version: "14.6"
platform:
family: iOS
-
user_agent: Mozilla/5.0 (Macintosh; ARM Mac OS X) AppleWebKit/538.15 (KHTML, like Gecko) Safari/538.15 Version/6.0 Raspbian/8.0 (1:3.8.2.0-0rpi27rpi1g) Epiphany/3.8.2
os:
name: Raspbian
short_name: RAS
version: "8.0"
liviuconcioiu marked this conversation as resolved.
Show resolved Hide resolved
platform: ARM
family: GNU/Linux
-
user_agent: Mozilla/5.0 (Macintosh; ARM Mac OS X) AppleWebKit/538.15 (KHTML, like Gecko) Safari/538.15 Version/6.0 Raspbian/9.0 (1:3.8.2.0-0rpi28) Epiphany/3.8.2
os:
name: Raspbian
short_name: RAS
version: "9.0"
platform: ARM
family: GNU/Linux
-
user_agent: Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Raspbian Chromium/72.0.3626.121 Chrome/72.0.3626.121 Safari/537.36
os:
name: Raspberry Pi OS
short_name: PIO
version: ""
platform: ARM
family: GNU/Linux
-
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36 UOS
os:
name: UOS
short_name: UOS
version: ""
platform: x64
family: GNU/Linux
-
user_agent: 'Mozilla/5.0 (X11; Linux x86_64; PICO 4 OS5.4.0 like Quest) AppleWebKit/537.36 (KHTML, like Gecko) PicoBrowser/3.3.22 Chrome/105.0.5195.68 VR Safari/537.36 OculusBrowser/7.0'
os:
name: PICO OS
short_name: PIC
version: 5.4.0
platform: x64
family: Android
headers:
Sec-CH-UA-Platform: "Android"
Sec-CH-UA-Platform-Version: "10.0.0"
-
user_agent: WhatsApp/2.22.9.78 A
os:
Expand Down
4 changes: 2 additions & 2 deletions Tests/fixtures/desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
os:
name: Debian
version: "6.0.1"
platform: ""
platform: SPARC64
client:
type: browser
name: IceCat
Expand Down Expand Up @@ -1119,7 +1119,7 @@
user_agent: Mozilla/5.0 (OS/2; Warp 4.5; rv:10.0.12) Gecko/20100101 Firefox/10.0.12
os:
name: OS/2
version: ""
version: "4.5"
platform: ""
client:
type: browser
Expand Down
5 changes: 5 additions & 0 deletions regexes/client/browsers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
# @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later
###############

# Raspbian Chromium (https://www.raspbian.org/)
- regex: 'Raspbian Chromium/(?:(\d+[\.\d]+))?'
name: 'Raspbian Chromium'
version: '$1'

# Quick Search TV (https://play.google.com/store/apps/details?id=com.aospstudio.tvsearch)
- regex: 'Quick Search TV(?:/(?:Wild Moon Edition )?(\d+[\.\d]+))?'
name: 'Quick Search TV'
Expand Down
26 changes: 26 additions & 0 deletions regexes/oss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@
# @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later
###############

##########
# UOS (https://www.chinauos.com/)
##########
- regex: 'UOS$'
name: 'UOS'
version: ''

##########
# Raspbian (https://www.raspbian.org/)
##########
- regex: 'Raspbian/(\d+[\.\d]+)'
name: 'Raspbian'
version: '$1'

##########
# Raspberry Pi OS (https://www.raspberrypi.com/software/)
##########
- regex: 'Raspbian'
name: 'Raspberry Pi OS'
version: ''

##########
# BrightSignOS (https://www.brightsign.biz/ecosystem/brightsign-os/)
##########
- regex: 'BrightSign/(?:[A-Z0-9]+)/(\d+[\.\d]+)'
Expand Down Expand Up @@ -1533,6 +1555,10 @@
##########
# IBM
##########
- regex: 'OS/2; Warp (\d+[\.\d]+)'
name: 'OS/2'
version: '$1'

- regex: 'OS/2'
name: 'OS/2'
version: ''
Expand Down
Loading