From 59fb555c303eac7cd8fe6e9d0a56347faa2a3ad5 Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Thu, 1 Feb 2024 11:11:51 +0100 Subject: [PATCH] Improves version detection for iOS, macOS and Iridium (#7572) * Improves version detection for Iridium * Improves version detection for iOS and macOS --- Parser/Client/Browser.php | 12 +++--------- Tests/Parser/Client/fixtures/browser.yml | 11 +++++++++++ Tests/Parser/fixtures/oss.yml | 16 ++++++++++++++++ regexes/oss.yml | 4 ++++ 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Parser/Client/Browser.php b/Parser/Client/Browser.php index 6f38cb69ac..1a331f3e62 100644 --- a/Parser/Client/Browser.php +++ b/Parser/Client/Browser.php @@ -816,15 +816,9 @@ public function parse(): ?array // If the version reported from the client hints is YYYY or YYYY.MM (e.g., 2022 or 2022.04), // then it is the Iridium browser // https://iridiumbrowser.de/news/ - if (0 === \strpos($version, '2020') - || 0 === \strpos($version, '2021') - || 0 === \strpos($version, '2022') - || 0 === \strpos($version, '2023') - ) { - $name = 'Iridium'; - $short = 'I1'; - $engine = $browserFromUserAgent['engine']; - $engineVersion = $browserFromUserAgent['engine_version']; + if (\preg_match('/^202[0-4]/', $version)) { + $name = 'Iridium'; + $short = 'I1'; } if ('Atom' === $name || 'Huawei Browser' === $name) { diff --git a/Tests/Parser/Client/fixtures/browser.yml b/Tests/Parser/Client/fixtures/browser.yml index cda4ef4189..a6b271c4e1 100644 --- a/Tests/Parser/Client/fixtures/browser.yml +++ b/Tests/Parser/Client/fixtures/browser.yml @@ -7926,3 +7926,14 @@ family: Chrome headers: Sec-CH-UA: '"Not_A Brand";v="8.0.0.0", "Chromium";v="120.0.6099.230", "DuckDuckGo";v="120.0.6099.230"' +- + user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.224 Safari/537.36 + client: + type: browser + name: Iridium + version: "2024.01" + engine: Blink + engine_version: 120.0.6099.224 + family: Chrome + headers: + Sec-CH-UA: '" Not A;Brand";v="99.0.0.0", "Chromium";v="2024.01"' diff --git a/Tests/Parser/fixtures/oss.yml b/Tests/Parser/fixtures/oss.yml index 9d04e7656e..63a65f3cbd 100644 --- a/Tests/Parser/fixtures/oss.yml +++ b/Tests/Parser/fixtures/oss.yml @@ -4126,3 +4126,19 @@ version: "14.3" platform: family: Mac +- + user_agent: Aloha/1 CFNetwork/1494.0.5 Darwin/23.4.0 + os: + name: iOS + short_name: IOS + version: "17.4" + platform: + family: iOS +- + user_agent: Safari/19617.7.20.11.12 CFNetwork/1494.0.5 Darwin/23.4.0 + os: + name: Mac + short_name: MAC + version: "14.4" + platform: + family: Mac diff --git a/regexes/oss.yml b/regexes/oss.yml index 688a652d3a..aa3e3acc54 100644 --- a/regexes/oss.yml +++ b/regexes/oss.yml @@ -871,6 +871,8 @@ - regex: '^(?!com.apple.Safari.SearchHelper|Safari).*CFNetwork/.+ Darwin/(\d+[\.\d]+)(?!.*(?:x86_64|i386|PowerMac|Power%20Macintosh))' name: 'iOS' versions: + - regex: 'Darwin/23.4.0' + version: '17.4' - regex: 'Darwin/23.3.0' version: '17.3' - regex: 'Darwin/23.2.0' @@ -1100,6 +1102,8 @@ - regex: '(?:CFNetwork|StudioDisplay)/.+Darwin(?:/|; )(?:[\d\.]+).+(?:x86_64|i386|Power%20Macintosh)|(?:x86_64-apple-)?darwin(?:[\d\.]+)|PowerMac|com.apple.Safari.SearchHelper|^Safari' name: 'Mac' versions: + - regex: '(?:x86_64-apple-)?Darwin(?:/|; )?23.4.0' + version: '14.4' - regex: '(?:x86_64-apple-)?Darwin(?:/|; )?23.3.0' version: '14.3' - regex: '(?:x86_64-apple-)?Darwin(?:/|; )?23.2.0'