Skip to content

Commit 8cb6ffb

Browse files
committed
Add new style Android user agent string
1 parent 3d48054 commit 8cb6ffb

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/Analyser/Header/Useragent/Os.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ private function detectAndroid($ua)
260260
if (preg_match('/;\+? ?(?:\*\*)?([^;]*[^;\s]);?\s+(?:BUILD|Build|build)/u', $ua, $match)) {
261261
$candidates[] = $match[1];
262262
}
263+
} elseif (preg_match('/\(Linux; Android [0-9\.]+; ([^\/]+)\) AppleWebKit/u', $ua, $match)) {
264+
/* New style minimal Android useragent string */
265+
266+
$candidates[] = $match[1];
263267
} elseif (preg_match('/Release\//ui', $ua)) {
264268
/* WAP style useragent strings */
265269

tests/data/mobile/os-android.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,23 @@
346346
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'
347347
readable: 'Tenta Browser 3.1.6 on a vivo 1915 running Android 9'
348348
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' } }
349+
-
350+
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'
351+
readable: 'Chrome 100 on a Motorola Moto G60 running Android 11'
352+
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' } }
353+
-
354+
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'
355+
readable: 'Chrome 100 on a Motorola Moto G60s running Android 11'
356+
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' } }
357+
-
358+
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'
359+
readable: 'Chrome 100 on a Google Pixel 4a 5G running Android 11'
360+
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' } }
361+
-
362+
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'
363+
readable: 'Chrome 99 on a Motorola Moto E6i running Android 10'
364+
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' } }
365+
-
366+
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'
367+
readable: 'Chrome 100 on a Motorola Moto G9 Play running Android 11'
368+
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 commit comments

Comments
 (0)