WhichBrowser / Parser-PHP

Browser sniffing gone too far — A useragent parser library for PHP
http://whichbrowser.net
MIT License
1.79k stars 240 forks source link

Cannot detect Mac OSX 11. #620

Closed st8st8 closed 3 years ago

st8st8 commented 3 years ago

From lines 101 the regex in Analyser/Header/Useragent to detect Max OS X only matches 10 versions.. Version 11 has now been released

    if (preg_match('/Mac OS X (10[0-9\._]*)/u', $ua, $match)) {
                $this->data->os->version = new Version([ 'value' => str_replace('_', '.', $match[1]), 'details' => 2 ]);
            }

            if (preg_match('/;os=Mac (10[0-9[\.,]*)/u', $ua, $match)) {
                $this->data->os->version = new Version([ 'value' => str_replace(',', '.', $match[1]), 'details' => 2 ]);
            }
cubicwork commented 3 years ago

same issue, can not get osversion.

Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Safari/537.36

bigcalm commented 3 years ago

Very short term fix for use with version 2.0.42:

if ($whichBrowser->isOs('OS X') && $whichBrowser->os->version === null) { ... }

Doing this makes me feel uneasy. But it's enough for the sake of working out if image/webp should be used or not.

joostvanhoof commented 3 years ago

The pull request is still open and I think this can be merged?

NielsLeenheer commented 3 years ago

The PR has been merged and will be included in the next release.

NielsLeenheer commented 3 years ago

That said, Safari on Big Sur has fixed the OS version in the user agent string. So it will report macOS Catalina, for example: "You are using Safari 14.0.1 on macOS Catalina 10.15", while I am Big Sur 11.0.1.