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

Improves detection for Chrome OS #7853

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Parser/OperatingSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,18 @@ public static function getShortOsData(string $name): array
*/
public function parse(): ?array
{
// is freeze user-agent then restoring the original UA for the device definition
if (null !== $this->clientHints
&& '' !== $this->clientHints->getModel()
&& $this->matchUserAgent('X11; Linux x86_64')
) {
$this->setUserAgent((string) \preg_replace(
'(X11; Linux x86_64)',
\sprintf('X11; Linux x86_64; %s', $this->clientHints->getModel()),
$this->userAgent
));
}

$osFromClientHints = $this->parseOsFromClientHints();
$osFromUserAgent = $this->parseOsFromUserAgent();

Expand Down Expand Up @@ -436,6 +448,15 @@ public function parse(): ?array
$name = $osFromUserAgent['name'];
$short = $osFromUserAgent['short_name'];
}

// Chrome OS is in some cases reported as Android in client hints
if ('Android' === $name
&& 'Chrome OS' === $osFromUserAgent['name']
) {
$name = $osFromUserAgent['name'];
$version = '';
$short = $osFromUserAgent['short_name'];
}
} elseif (!empty($osFromUserAgent['name'])) {
$name = $osFromUserAgent['name'];
$version = $osFromUserAgent['version'];
Expand Down
325 changes: 325 additions & 0 deletions Tests/fixtures/clienthints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3605,6 +3605,331 @@
model: HK1RBOX-X4
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.50
headers:
Sec-CH-UA: '" Not A;Brand";v="99.0.0.0", "Chromium";v="100.0.4896.127"'
Sec-CH-UA-Platform: "Android"
Sec-CH-UA-Mobile: "?0"
Sec-CH-UA-Full-Version: "100.0.4896.127"
Sec-CH-UA-Platform-Version: "11.0.0"
Sec-CH-UA-Model: "octopus"
os:
name: Chrome OS
version: ""
platform: x64
client:
type: browser
name: Opera
version: 86.0.4363.50
engine: Blink
engine_version: 100.0.4896.127
device:
type: desktop
brand: ""
model: octopus
os_family: Chrome OS
browser_family: Opera
-
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.134 Safari/537.36 OPR/88.0.4412.53
headers:
Sec-CH-UA: '" Not A;Brand";v="99.0.0.0", "Chromium";v="102.0.5005.134"'
Sec-CH-UA-Platform: "Android"
Sec-CH-UA-Mobile: "?0"
Sec-CH-UA-Full-Version: "102.0.5005.134"
Sec-CH-UA-Platform-Version: "9.0.0"
Sec-CH-UA-Model: "trogdor"
os:
name: Chrome OS
version: ""
platform: x64
client:
type: browser
name: Opera
version: 88.0.4412.53
engine: Blink
engine_version: 102.0.5005.134
device:
type: desktop
brand: ""
model: trogdor
os_family: Chrome OS
browser_family: Opera
-
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.97 Safari/537.36 OPR/90.0.4480.54
headers:
Sec-CH-UA: '" Not A;Brand";v="99.0.0.0", "Chromium";v="104.0.5112.97"'
Sec-CH-UA-Platform: "Android"
Sec-CH-UA-Mobile: "?0"
Sec-CH-UA-Full-Version: "104.0.5112.97"
Sec-CH-UA-Platform-Version: "9.0.0"
Sec-CH-UA-Model: "kukui"
os:
name: Chrome OS
version: ""
platform: x64
client:
type: browser
name: Opera
version: 90.0.4480.54
engine: Blink
engine_version: 104.0.5112.97
device:
type: desktop
brand: ""
model: kukui
os_family: Chrome OS
browser_family: Opera
-
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.97 Safari/537.36 OPR/90.0.4480.54
headers:
Sec-CH-UA: '" Not A;Brand";v="99.0.0.0", "Chromium";v="104.0.5112.97"'
Sec-CH-UA-Platform: "Android"
Sec-CH-UA-Mobile: "?0"
Sec-CH-UA-Full-Version: "104.0.5112.97"
Sec-CH-UA-Platform-Version: "9.0.0"
Sec-CH-UA-Model: "rammus"
os:
name: Chrome OS
version: ""
platform: x64
client:
type: browser
name: Opera
version: 90.0.4480.54
engine: Blink
engine_version: 104.0.5112.97
device:
type: desktop
brand: ""
model: rammus
os_family: Chrome OS
browser_family: Opera
-
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.5249.126 Safari/537.36 OPR/92.0.4561.11
headers:
Sec-CH-UA: '"Not;A=Brand";v="99.0.0.0", "Chromium";v="106.0.5249.126"'
Sec-CH-UA-Platform: "Android"
Sec-CH-UA-Mobile: "?0"
Sec-CH-UA-Full-Version: "106.0.5249.126"
Sec-CH-UA-Platform-Version: "11.0.0"
Sec-CH-UA-Model: "hatch"
os:
name: Chrome OS
version: ""
platform: x64
client:
type: browser
name: Opera
version: 92.0.4561.11
engine: Blink
engine_version: 106.0.5249.126
device:
type: desktop
brand: ""
model: hatch
os_family: Chrome OS
browser_family: Opera
-
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.196 Safari/537.36 OPR/100.0.4815.13
headers:
Sec-CH-UA: '"Not.A/Brand";v="8.0.0.0", "Chromium";v="114.0.5735.196"'
Sec-CH-UA-Platform: "Android"
Sec-CH-UA-Mobile: "?0"
Sec-CH-UA-Full-Version: "114.0.5735.196"
Sec-CH-UA-Platform-Version: "11.0.0"
Sec-CH-UA-Model: "nami"
os:
name: Chrome OS
version: ""
platform: x64
client:
type: browser
name: Opera
version: 100.0.4815.13
engine: Blink
engine_version: 114.0.5735.196
device:
type: desktop
brand: ""
model: nami
os_family: Chrome OS
browser_family: Opera
-
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.5790.167 Safari/537.36 OPR/101.0.4843.33
headers:
Sec-CH-UA: '"Chromium";v="115.0.5790.167", "Not/A)Brand";v="99.0.0.0"'
Sec-CH-UA-Platform: "Android"
Sec-CH-UA-Mobile: "?0"
Sec-CH-UA-Full-Version: "115.0.5790.167"
Sec-CH-UA-Platform-Version: "11.0.0"
Sec-CH-UA-Model: "brya"
os:
name: Chrome OS
version: ""
platform: x64
client:
type: browser
name: Opera
version: 101.0.4843.33
engine: Blink
engine_version: 115.0.5790.167
device:
type: desktop
brand: ""
model: brya
os_family: Chrome OS
browser_family: Opera
-
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.5938.154 Safari/537.36 OPR/103.0.4928.26
headers:
Sec-CH-UA: '"Chromium";v="117.0.5938.154", "Not;A=Brand";v="8.0.0.0"'
Sec-CH-UA-Platform: "Android"
Sec-CH-UA-Mobile: "?0"
Sec-CH-UA-Full-Version: "117.0.5938.154"
Sec-CH-UA-Platform-Version: "11.0.0"
Sec-CH-UA-Model: "dedede"
os:
name: Chrome OS
version: ""
platform: x64
client:
type: browser
name: Opera
version: 103.0.4928.26
engine: Blink
engine_version: 117.0.5938.154
device:
type: desktop
brand: ""
model: dedede
os_family: Chrome OS
browser_family: Opera
-
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.5938.154 Safari/537.36 OPR/103.0.4928.26
headers:
Sec-CH-UA: '"Chromium";v="117.0.5938.154", "Not;A=Brand";v="8.0.0.0"'
Sec-CH-UA-Platform: "Android"
Sec-CH-UA-Mobile: "?0"
Sec-CH-UA-Full-Version: "117.0.5938.154"
Sec-CH-UA-Platform-Version: "11.0.0"
Sec-CH-UA-Model: "nissa"
os:
name: Chrome OS
version: ""
platform: x64
client:
type: browser
name: Opera
version: 103.0.4928.26
engine: Blink
engine_version: 117.0.5938.154
device:
type: desktop
brand: ""
model: nissa
os_family: Chrome OS
browser_family: Opera
-
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.280 Safari/537.36 OPR/106.0.4998.28
headers:
Sec-CH-UA: '"Not_A Brand";v="8.0.0.0", "Chromium";v="120.0.6099.280"'
Sec-CH-UA-Platform: "Android"
Sec-CH-UA-Mobile: "?0"
Sec-CH-UA-Full-Version: "120.0.6099.280"
Sec-CH-UA-Platform-Version: "13.0.0"
Sec-CH-UA-Model: "volteer"
os:
name: Chrome OS
version: ""
platform: x64
client:
type: browser
name: Opera
version: 106.0.4998.28
engine: Blink
engine_version: 120.0.6099.280
device:
type: desktop
brand: ""
model: volteer
os_family: Chrome OS
browser_family: Opera
-
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.149 Safari/537.36 OPR/108.0.5067.24
headers:
Sec-CH-UA: '"Not(A:Brand";v="24.0.0.0", "Chromium";v="122.0.6261.149"'
Sec-CH-UA-Platform: "Android"
Sec-CH-UA-Mobile: "?0"
Sec-CH-UA-Full-Version: "122.0.6261.149"
Sec-CH-UA-Platform-Version: "11.0.0"
Sec-CH-UA-Model: "strongbad"
os:
name: Chrome OS
version: ""
platform: x64
client:
type: browser
name: Opera
version: 108.0.5067.24
engine: Blink
engine_version: 122.0.6261.149
device:
type: desktop
brand: ""
model: strongbad
os_family: Chrome OS
browser_family: Opera
-
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Safari/537.36 OPR/85.0.4341.13
headers:
Sec-CH-UA: '" Not A;Brand";v="99.0.0.0", "Chromium";v="99.0.4844.88"'
Sec-CH-UA-Platform: "Android"
Sec-CH-UA-Mobile: "?0"
Sec-CH-UA-Full-Version: "99.0.4844.88"
Sec-CH-UA-Platform-Version: "9.0.0"
Sec-CH-UA-Model: "coral"
os:
name: Chrome OS
version: ""
platform: x64
client:
type: browser
name: Opera
version: 85.0.4341.13
engine: Blink
engine_version: 99.0.4844.88
device:
type: desktop
brand: ""
model: coral
os_family: Chrome OS
browser_family: Opera
-
user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Safari/537.36 OPR/85.0.4341.13
headers:
Sec-CH-UA: '" Not A;Brand";v="99.0.0.0", "Chromium";v="99.0.4844.88"'
Sec-CH-UA-Platform: "Android"
Sec-CH-UA-Mobile: "?0"
Sec-CH-UA-Full-Version: "99.0.4844.88"
Sec-CH-UA-Platform-Version: "9.0.0"
Sec-CH-UA-Model: "jacuzzi"
os:
name: Chrome OS
version: ""
platform: x64
client:
type: browser
name: Opera
version: 85.0.4341.13
engine: Blink
engine_version: 99.0.4844.88
device:
type: desktop
brand: ""
model: jacuzzi
os_family: Chrome OS
browser_family: Opera
-
user_agent: Mozilla/5.0 (Linux; Android 11) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/126.0.0.0 Mobile DuckDuckGo/5 Safari/537.36
headers:
Expand Down
6 changes: 6 additions & 0 deletions regexes/oss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,12 @@
name: 'Chrome OS'
version: '$1'

# Codename is present only in generated user-agent from client hints
# https://chromiumdash.appspot.com/serving-builds?deviceCategory=ChromeOS
- regex: 'Linux x86_64; (?:asurada|atlas|brask|brya|cherry|coral|corsola|dedede|drallion|elm|eve|fizz|geralt|grunt|guybrush|hana|hatch|jacuzzi|kalista|kukui|nami|nautilus|nissa|nocturne|octopus|puff|pyro|rammus|reef|rex|sand|sarien|skyrim|snappy|soraka|staryu|strongbad|trogdor|volteer|zork)'
name: 'Chrome OS'
version: ''

##########
# Android TV (https://android.com/tv/)
##########
Expand Down
Loading