Edit report at https://bugs.php.net/bug.php?id=65550&edit=1
ID: 65550 Comment by: oliver at realtsp dot com Reported by: quentin389 at gmail dot com Summary: get_browser() incorrectly parsers entries with "+" sign. Status: Open Type: Bug Package: Unknown/Other Function Operating System: Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: I can confirm this bug on php 5.4.14 using this browscap file: http://tempdownloads.browserscap.com/stream.asp?PHP_BrowsCapINI "Mozilla/5.0 (compatible; AhrefsBot/5.0; +http://ahrefs.com/robot/)" is not recognised Previous Comments: ------------------------------------------------------------------------ [2013-08-25 15:27:57] quentin389 at gmail dot com Description: ------------ get_browser() incorrectly handles entries from browscap.ini files when they have "+" sign in the pattern match. The "+" in the ini files is a LITERAL character, not a wildcard match. The only wildcard that browscap.ini source files use are "*" and "?". The result of that is that none of the browscap.ini entries that have a match pattern with "+" ever match the browsers that they are supposed to match. My suspicion is that if you'd change https://github.com/php/php-src/blob/master/ext/standard/browscap.c#L110 and add: case '+': t[j++] = '\\'; t[j] = '+'; break; everything would be fixed. But I haven't tested that. Test script: --------------- // browscap.ini entry: // [Mozilla/5.0 (compatible; AhrefsBot/*; +http://ahrefs.com/robot/)] // Parent="Search Engines" // Browser="AhrefsBot" echo "<pre>"; var_dump(get_browser('Mozilla/5.0 (compatible; AhrefsBot/4.0; +http://ahrefs.com/robot/)')); Expected result: ---------------- object(stdClass)#2 (35) { (...) ["Browser"]=> string(9) "AhrefsBot" Actual result: -------------- object(stdClass)#1 (34) { (...) ["browser"]=> string(15) "Default Browser" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65550&edit=1