php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80606 get_browser returns Chrome instead of Edge on MacOS
Submitted: 2021-01-07 15:56 UTC Modified: 2021-01-08 10:43 UTC
From: raul dot tabasso at tabasoft dot it Assigned: cmb (profile)
Status: Not a bug Package: Unknown/Other Function
PHP Version: 7.4.14 OS: MacOS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
28 + 23 = ?
Subscribe to this entry?

 
 [2021-01-07 15:56 UTC] 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"


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-07 17:21 UTC] raul dot tabasso at tabasoft dot it
Also tested with php 8.0 same result
 [2021-01-07 17:38 UTC] 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:41 UTC] rtrtrtrtrt at dfdfdfdf dot dfd
> 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
 [2021-01-07 17:45 UTC] raul dot tabasso at tabasoft dot it
Can you suggest a good client side solution that reliably extracts browser, version and os?
 [2021-01-07 17:50 UTC] rtrtrtrtrt at dfdfdfdf dot dfd
> Can you suggest a good client side solution that 
> reliably extracts browser, version and os?

i suggest to write proper code which works on every more or less up-to-date client
 [2021-01-08 10:43 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-01-08 10:43 UTC] cmb@php.net
> The problem is in the browscap.ini lite file that strangely
> doesn't include edge USER_AGENT for macOS!

Consider to report that upstream.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jul 05 09:05:45 2022 UTC