Skip to content

Commit

Permalink
Add new style Android user agent string
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsLeenheer committed Apr 11, 2022
1 parent 3d48054 commit 8cb6ffb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Analyser/Header/Useragent/Os.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ private function detectAndroid($ua)
if (preg_match('/;\+? ?(?:\*\*)?([^;]*[^;\s]);?\s+(?:BUILD|Build|build)/u', $ua, $match)) {
$candidates[] = $match[1];
}
} elseif (preg_match('/\(Linux; Android [0-9\.]+; ([^\/]+)\) AppleWebKit/u', $ua, $match)) {
/* New style minimal Android useragent string */

$candidates[] = $match[1];
} elseif (preg_match('/Release\//ui', $ua)) {
/* WAP style useragent strings */

Expand Down
20 changes: 20 additions & 0 deletions tests/data/mobile/os-android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,23 @@
headers: 'User-Agent: Mozilla/5.0 (Linux; U; Android 9; th; vivo 1915) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.137 Mobile Tenta/3.1.6 Build/2162 Safari/537.36'
readable: 'Tenta Browser 3.1.6 on a vivo 1915 running Android 9'
result: { browser: { name: 'Tenta Browser', family: { name: Chrome, version: 64 }, version: 3.1.6, type: browser }, engine: { name: Blink }, os: { name: Android, version: '9' }, device: { type: mobile, subtype: smart, model: 'vivo 1915' } }
-
headers: 'User-Agent: Mozilla/5.0 (Linux; Android 11; moto g(60)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.79 Mobile Safari/537.36'
readable: 'Chrome 100 on a Motorola Moto G60 running Android 11'
result: { browser: { name: Chrome, version: '100', type: browser }, engine: { name: Blink }, os: { name: Android, version: '11' }, device: { type: mobile, subtype: smart, manufacturer: Motorola, model: 'Moto G60' } }
-
headers: 'User-Agent: Mozilla/5.0 (Linux; Android 11; moto g(60)s) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.79 Mobile Safari/537.36'
readable: 'Chrome 100 on a Motorola Moto G60s running Android 11'
result: { browser: { name: Chrome, version: '100', type: browser }, engine: { name: Blink }, os: { name: Android, version: '11' }, device: { type: mobile, subtype: smart, manufacturer: Motorola, model: 'Moto G60s' } }
-
headers: 'User-Agent: Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.79 Mobile Safari/537.36'
readable: 'Chrome 100 on a Google Pixel 4a 5G running Android 11'
result: { browser: { name: Chrome, version: '100', type: browser }, engine: { name: Blink }, os: { name: Android, version: '11' }, device: { type: mobile, subtype: smart, manufacturer: Google, model: 'Pixel 4a 5G' } }
-
headers: 'User-Agent: Mozilla/5.0 (Linux; Android 10; moto e(6i) Build/QOHS30.280-7-9) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36'
readable: 'Chrome 99 on a Motorola Moto E6i running Android 10'
result: { browser: { name: Chrome, version: '99', type: browser }, engine: { name: Blink }, os: { name: Android, version: '10' }, device: { type: mobile, subtype: smart, manufacturer: Motorola, model: 'Moto E6i' } }
-
headers: 'User-Agent: Mozilla/5.0 (Linux; Android 11; moto g(9) play) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.79 Mobile Safari/537.36'
readable: 'Chrome 100 on a Motorola Moto G9 Play running Android 11'
result: { browser: { name: Chrome, version: '100', type: browser }, engine: { name: Blink }, os: { name: Android, version: '11' }, device: { type: mobile, subtype: smart, manufacturer: Motorola, model: 'Moto G9 Play' } }

0 comments on commit 8cb6ffb

Please sign in to comment.