browserslist/browserslist-useragent-regexp

Opera Mini pretends to be Chrome 74?

MeLlamoPablo opened this issue · 5 comments

Hello, I am developing a React single page app. By default, create-react-app uses the following browserlist:

>0.2%
not dead
not op_mini all

Based on that, and seing that Opera Mini lacks many features, I would like to warn Opera Mini users to use the app in a different browser.

However, it appears that the generated regex identifies Opera Mini as Chrome 74:

The following browserlist query:

chrome >= 74

Compiles to the following regex:

/(HeadlessChrome((?:\/74\.0\.\d+)?|(?:\/74\.([1-9]|\d{2,})\.\d+)?|(?:\/(7[5-9]|[8-9]\d|\d{3,})\.\d+\.\d+)?))|((Chromium|Chrome)\/(74\.0|74\.([1-9]|\d{2,})|(7[5-9]|[8-9]\d|\d{3,})\.\d+)(?:\.\d+)?)/

And Opera Mini has the following user agent:

Mozilla/5.0 (Linux; U; Android 9; CLT-L09 Build/HUAWEICLT-L09; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.136 Mobile Safari/537.36 OPR/50.0.2254.149180

Which satisfies the generated regex. It seems that the useful bit is OPR/50.0.2254.149180, which is undetected by the regex. Is there a change that this bit could be identified?

@MeLlamoPablo Hi!

seing that Opera Mini lacks many features

Opera Mini what you mean is based on Presto engine and have different user agent:

browserslist-useragent-regexp "op_mini all" -v                 

> Browserslist

operamini  all


> RegExps

Family:                           operamini                                               
Versions:                         all                                                     
Source RegExp:                    /(OperaMini)(?:\/att)?\/?(\d+)?(?:\.(\d+))?(?:\.(\d+))?/
Source RegExp fixed version:      ...                                                     
Source RegExp browsers versions:  ... - ...                                               
Versioned RegExp:                 /OperaMini(?:\/att)?\/?(\d+)?(?:\.\d+)?(?:\.\d+)?/      


/(OperaMini(?:\/att)?\/?(\d+)?(?:\.\d+)?(?:\.\d+)?)/

Mozilla/5.0 (Linux; U; Android 9; CLT-L09 Build/HUAWEICLT-L09; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.136 Mobile Safari/537.36 OPR/50.0.2254.149180

This browser actually is Chrome-based browser and has all Chrome features.

Here I see another thing: /OperaMini(?:\/att)?\/?(\d+)?(?:\.\d+)?(?:\.\d+)?/ is wrong regex, it should have Opera Mini instead of Opera Mini. I will made issue and fix soon.

Hello, thanks for the quick response. If it is chromium based I see nothing wrong with supporting it. However, which browser is actually targeted by the op_mini all query?

I tried the two Opera browsers available on the Play store and extracted their user agents:

  1. Opera

    Mozilla/5.0 (Linux; Android 9; FP3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Mobile Safari/537.36 OPR/58.2.2878.53403
    
  2. Opera Mini

    Mozilla/5.0 (Linux; U; Android 9; FP3 Build/8901.2.A.0123.20200515; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.96 Mobile Safari/537.36 OPR/50.0.2254.149182
    

So both of them are Chrome based? Do you know where I can find the Presto-based browser to test that the regex is working correctly?

Thank you so much.

So both of them are Chrome based?

Yes

Do you know where I can find the Presto-based browser to test that the regex is working correctly?

On old mobile phones with buttons and Java apps support 🙂

Here you can find user agents examples:
https://developers.whatismybrowser.com/useragents/explore/software_name/opera-mini/

Thank you! I downloaded an old APK and the regex works correctly :)