-
-
Notifications
You must be signed in to change notification settings - Fork 489
Description
When parsing a User Agent string from an Android WebView (; wv) on a Motorola "Edge" series device, Bowser incorrectly identifies the browser family as "Microsoft Edge" with no version. The browser keyword "edge" is being matched from the device model name in the UA string rather than from a browser token.
Affected UA strings:
Mozilla/5.0 (Linux; Android 16; motorola edge 60 fusion Build/W1VC36H.14-20-19; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/144.0.7559.132 Mobile Safari/537.36 IITtraderNative DCASupport1/5 Mobile
Mozilla/5.0 (Linux; Android 15; motorola edge 50 fusion Build/V1UUIS35H.15-41-6-18-2; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/145.0.7632.79 Mobile Safari/537.36 IITtraderNative DCASupport1/5 Mobile
Steps to reproduce:
import * as Bowser from 'bowser';
const ua = 'Mozilla/5.0 (Linux; Android 16; motorola edge 60 fusion Build/W1VC36H.14-20-19; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/144.0.7559.132 Mobile Safari/537.36 IITtraderNative DCASupport1/5 Mobile';
const result = Bowser.getParser(ua).getResult();
console.log(result.browser); // { name: 'Microsoft Edge' } ← wrong, no version
console.log(result.os); // { name: 'Android', version: '16' } ← correct
Current behaviour:
Bowser matches the string "edge" from "motorola edge 60 fusion" inside the UA's device model section (between the first ( and ;) and treats it as the Edge browser token. No version is captured because there is no /N.N following it.
result.browser = { name: 'Microsoft Edge' } // version: undefined
result.engine = { name: 'EdgeHTML', version: '' }
Expected behaviour:
result.browser = { name: 'Chrome', version: '144.0.7559.132' }
// or equivalently: { name: 'Chrome WebView', version: '144.0.7559.132' }
The Chrome/144.0.7559.132 token is present and unambiguous. For Android WebViews (identified by ; wv)), the browser should be parsed from the Chrome/ token, not from arbitrary strings inside the device model segment of the UA.
Root cause:
The Edge browser regex in Bowser matches /edg([ea]|ios)/i which matches bare "edge" anywhere in the UA — including inside device model names in the platform section of the UA.