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 ASPLinux, SerenityOS, improves detection for Fire OS, improves version detection for Fire OS, Lineage OS and tvOS #7630

Merged
merged 14 commits into from
Mar 22, 2024
Merged
73 changes: 55 additions & 18 deletions Parser/OperatingSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class OperatingSystem extends AbstractParser
'ARM' => 'Armadillo OS',
'ATV' => 'tvOS',
'ARL' => 'Arch Linux',
'ASP' => 'ASPLinux',
'BTR' => 'BackTrack',
'SBA' => 'Bada',
'BEO' => 'BeOS',
Expand Down Expand Up @@ -152,6 +153,7 @@ class OperatingSystem extends AbstractParser
'SSE' => 'SUSE',
'SAF' => 'Sailfish OS',
'SEE' => 'SeewoOS',
'SER' => 'SerenityOS',
'SIR' => 'Sirin OS',
'SLW' => 'Slackware',
'SOS' => 'Solaris',
Expand Down Expand Up @@ -219,7 +221,7 @@ class OperatingSystem extends AbstractParser
'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', 'RAS',
'UOS', 'PIO', 'FRI', 'LIR', 'WEB',
'UOS', 'PIO', 'FRI', 'LIR', 'WEB', 'SER', 'ASP',
],
'Mac' => ['MAC'],
'Mobile Gaming Console' => ['PSP', 'NDS', 'XBX'],
Expand Down Expand Up @@ -305,6 +307,45 @@ public function parse(): ?array
$osFromClientHints = $this->parseOsFromClientHints();
$osFromUserAgent = $this->parseOsFromUserAgent();

$fireOsVersionMapping = [
'11' => '8',
'10' => '8',
'9' => '7',
'7' => '6',
'5' => '5',
'4.4.3' => '4.5.1',
'4.4.2' => '4',
'4.2.2' => '3',
'4.0.3' => '3',
'4.0.2' => '3',
'4' => '2',
'2' => '1',
];

$lineageOsVersionMapping = [
'14' => '21.0',
'13' => '20.0',
'12.1' => '19.1',
'12' => '19.0',
'11' => '18.0',
'10' => '17.0',
'9' => '16.0',
'8.1.0' => '15.1',
'8.0.0' => '15.0',
'7.1.2' => '14.1',
'7.1.1' => '14.1',
'7.0' => '14.0',
'6.0.1' => '13.0',
'6.0' => '13.0',
'5.1.1' => '12.1',
'5.0.2' => '12.0',
'5.0' => '12.0',
'4.4.4' => '11.0',
'4.3' => '10.2',
'4.2.2' => '10.1',
'4.0.4' => '9.1.0',
];
liviuconcioiu marked this conversation as resolved.
Show resolved Hide resolved

if (!empty($osFromClientHints['name'])) {
$name = $osFromClientHints['name'];
$version = $osFromClientHints['version'];
Expand Down Expand Up @@ -332,22 +373,7 @@ public function parse(): ?array
if ('Fire OS' === $osFromUserAgent['name']) {
$majorVersion = (int) (\explode('.', $version, 1)[0] ?? '0');

$fireOsVersionMapping = [
'11' => '8',
'10' => '8',
'9' => '7',
'7' => '6',
'5' => '5',
'4.4.3' => '4.5.1',
'4.4.2' => '4',
'4.2.2' => '3',
'4.0.3' => '3',
'4.0.2' => '3',
'4' => '2',
'2' => '1',
];

$version = $fireOsVersionMapping[$version] ?? $fireOsVersionMapping[$majorVersion] ?? $version;
$version = $fireOsVersionMapping[$version] ?? $fireOsVersionMapping[$majorVersion] ?? '';
}
}

Expand Down Expand Up @@ -385,10 +411,21 @@ public function parse(): ?array
}

if ('org.lineageos.jelly' === $this->clientHints->getApp() && 'Lineage OS' !== $name) {
$majorVersion = (int) (\explode('.', $version, 1)[0] ?? '0');

$name = 'Lineage OS';
$family = 'Android';
$short = 'LEN';
$version = '';
$version = $lineageOsVersionMapping[$version] ?? $lineageOsVersionMapping[$majorVersion] ?? '';
}

if ('org.mozilla.tv.firefox' === $this->clientHints->getApp() && 'Fire OS' !== $name) {
$majorVersion = (int) (\explode('.', $version, 1)[0] ?? '0');

$name = 'Fire OS';
$family = 'Android';
$short = 'FIR';
$version = $fireOsVersionMapping[$version] ?? $fireOsVersionMapping[$majorVersion] ?? '';
}
}

Expand Down
11 changes: 11 additions & 0 deletions Tests/Parser/Client/fixtures/browser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9023,3 +9023,14 @@
engine: WebKit
engine_version: 605.1.15
family:
-
user_agent: Mozilla/5.0 (Linux; Android 11) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Focus/4.5 Chrome/83.0.4103.120 Safari/537.36
client:
type: browser
name: Firefox Focus
version: "4.5"
engine: Blink
engine_version: 83.0.4103.120
family:
headers:
http-x-requested-with: org.mozilla.tv.firefox
Loading
Loading