Bug #80606 [Com]: get_browser returns Chrome instead of Edge on MacOS

From: Date: Thu, 07 Jan 2021 17:41:27 +0000
Subject: Bug #80606 [Com]: get_browser returns Chrome instead of Edge on MacOS
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231435@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80606&edit=1 ID: 80606 Comment by: rtrtrtrtrt at dfdfdfdf dot dfd Reported by: raul dot tabasso at tabasoft dot it Summary: get_browser returns Chrome instead of Edge on MacOS Status: Open Type: Bug Package: Unknown/Other Function Operating System: MacOS PHP Version: 7.4.14 Block user comment: N Private report: N New Comment: > You have to add manually or use the heavy browscap.ini files :( have fun - you need endless RAM for nothing and (while it got optimized somehow) after a ton of OOM killer events in 2016 just because of the browscap.ini stuff get_browser() is a forbidden function company wide (disable_functions) it's nonsense these days anyways to mangle around browsers serverside Previous Comments: ------------------------------------------------------------------------ [2021-01-07 17:38:02] raul dot tabasso at tabasoft dot it The problem is in the browscap.ini lite file that strangely doesn't include edge USER_AGENT for macOS! You have to add manually or use the heavy browscap.ini files :( ------------------------------------------------------------------------ [2021-01-07 17:21:37] raul dot tabasso at tabasoft dot it Also tested with php 8.0 same result ------------------------------------------------------------------------ [2021-01-07 15:56:43] raul dot tabasso at tabasoft dot it Description: ------------ PHP 7.4.12 [GJK_Browscap_Version] Version=6000042 Released=Mon, 07 Dec 2020 08:37:21 +0000 Format=php Type=LITE $_SERVER['HTTP_USER_AGENT'] is: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66" get_browser() returns Chrome instead of Edge As you can see at the end of HTTP_USER_AGENT there is "... Edg/87.0.664.66", but Chrome 87 is returned. Test script: --------------- $browser = get_browser(); dump ($browser); {#454 ▼ +"browser_name_regex": "~^mozilla/5\.0 \(.*mac os x.*\) applewebkit.* \(.*khtml.*like.*gecko.*\) chrome/87\.0.*safari/.*$~" +"browser_name_pattern": "Mozilla/5.0 (*Mac OS X*) applewebkit* (*khtml*like*gecko*) Chrome/87.0*Safari/*" +"parent": "Chrome 87.0" +"platform": "MacOSX" +"comment": "Chrome 87.0" +"browser": "Chrome" +"version": "87.0" +"device_type": "Desktop" +"ismobiledevice": "" +"istablet": "" } Expected result: ---------------- +"browser": "Edge" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80606&edit=1

« previous php.bugs (#231435) next »