Bug #65550 [Ana->Csd]: get_browser() incorrectly parses entries with "+" sign

From: Date: Fri, 26 Aug 2016 23:34:46 +0000
Subject: Bug #65550 [Ana->Csd]: get_browser() incorrectly parses entries with "+" sign
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203599@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65550&edit=1 ID: 65550 Updated by: cmb@php.net Reported by: quentin389 at gmail dot com Summary: get_browser() incorrectly parses entries with "+" sign -Status: Analyzed +Status: Closed Type: Bug Package: Unknown/Other Function Operating System: Linux PHP Version: Irrelevant Assigned To: cmb Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmbecker69@gmx.de Revision: http://git.php.net/?p=php-src.git;a=commit;h=2139918ea6f5088e9ed5daa734568b4a50217f52 Log: Fix #65550: get_browser() incorrectly parsers entries with &quot;+&quot; sign Previous Comments: ------------------------------------------------------------------------ [2016-08-26 22:58:01] cmb@php.net > The "+" in the ini files is a LITERAL character, not a wildcard > match. Indeed. Thanks! ------------------------------------------------------------------------ [2015-05-27 01:09:07] contact at willianveiga dot com I cannot reproduce this on master (b73f87b). Maybe it was already fixed. ------------------------------------------------------------------------ [2013-10-24 08:31:36] oliver at realtsp dot com 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 ------------------------------------------------------------------------ [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

« previous php.bugs (#203599) next »