DeviceDetector.NET icon indicating copy to clipboard operation
DeviceDetector.NET copied to clipboard

Microsoft Edge and Brave Browser detected as 'Iridium'

Open francescocristallo opened this issue 1 year ago • 7 comments

Using the default example, passing client user agent + client hints, Edge and Brave browsers, both on Desktop and mobile are Matched to Iridium even if they are clearly specified in sec-ch-ua hint:

Screenshot 2024-02-21 173354

This happens both in local and in live production. Tested from Windows 11 desktop and Android phone.

francescocristallo avatar Feb 21 '24 23:02 francescocristallo

I think the problem is here:

https://github.com/totpero/DeviceDetector.NET/blob/4e68900d2305d30ad1a016d45ae276fe80d29bae/DeviceDetector.NET/Parser/Client/BrowserParser.cs#L795

The condition is negated for some reason, so it always matches. (My Google Chrome is also detected as Iridium.)

I did a quick test with Iridium, and it doesn't actually send a version number like the one this tries to match. In fact, it doesn't send anything Iridium-specific at all.

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.140 Safari/537.36
Sec-Ch-Ua: "Not)A;Brand";v="24", "Chromium";v="116"
Sec-Ch-Ua-Full-Version-List: "Not)A;Brand";v="24.0.0.0", "Chromium";v="116.0"

dzsibi avatar Feb 23 '24 15:02 dzsibi

@francescocristallo and @dzsibi can you both try the PHP version of device-detector at https://devicedetector.lw1.at/ and report back if your browsers are detected correctly?

@dzsibi Iridium used to send client hints with year.

sec-ch-ua: "(Not(A:Brand";v="8", "Chromium";v="2022"
sec-ch-ua-full-version: "2022.04"
sec-ch-ua-mobile: ?0
sec-ch-ua-model
sec-ch-ua-platform: "Windows"
sec-ch-ua-platform-version: "15.0.0"
sec-fetch-dest: empty
sec-fetch-mode: cors
sec-fetch-site: same-origin
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36

liviuconcioiu avatar Feb 23 '24 16:02 liviuconcioiu

Yes, the PHP version correctly detects Google Chrome both with and without client hints. It has the same condition, but does not negate the result (the backslash is a namespace operator):

https://github.com/matomo-org/device-detector/blob/61bbb7113ac343bfde22f5f523a19b8d083e7afb/Parser/Client/Browser.php#L844

dzsibi avatar Feb 23 '24 17:02 dzsibi

Out of curiosity I checked why the tests didn't catch this: they are disabled. When #77 was merged, test runs were removed from the pipeline entirely:

https://github.com/totpero/DeviceDetector.NET/blob/4e68900d2305d30ad1a016d45ae276fe80d29bae/.github/workflows/dotnetcore.yml#L22-L23

dzsibi avatar Feb 23 '24 18:02 dzsibi

I confirm the PHP version correctly identify Edge , while Brave browser is detected as Chrome Mobile

francescocristallo avatar Feb 23 '24 23:02 francescocristallo

Hi @all Thanks for your feedback and contribution, I fix this in last release 6.3.1. Check if is ok now. Thanks 👍

totpero avatar Feb 29 '24 10:02 totpero

Unfortunately @totpero, this does not seem to fix the issue. For reference, here is some code that reproduces it with the latest version:

using DeviceDetectorNET;

var headers = new Dictionary<string, string>
{
    ["Sec-Ch-Ua-Full-Version-List"] = "\"Chromium\";v=\"122.0.6261.69\", \"Not(A:Brand\";v=\"24.0.0.0\", \"Google Chrome\";v=\"122.0.6261.69\"",
};
var userAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36";
var detector = new DeviceDetector(userAgent, ClientHints.Factory(headers));
detector.Parse();
Console.WriteLine(detector.GetBrowserClient().Match);

This will print:

Type: browser; 
 Name: Iridium;
 Version: 122.0.6261.69;
 ShortName: I1; 
 Engine: Blink; 
 EngineVersion: 122.0.0.0;
 Family: Chrome;

I believe that the real issue is still the negation of the condition in BrowserParser:

https://github.com/totpero/DeviceDetector.NET/blob/521bd5be15c047bb2626353666582474bbb4b534/DeviceDetector.NET/Parser/Client/BrowserParser.cs#L795

dzsibi avatar Mar 04 '24 12:03 dzsibi

Hi @dzsibi , Now this is fixed, you can test with 6.3.3 release. Thanks for your feedback 👍

totpero avatar Mar 19 '24 16:03 totpero