From:             quentin389 at gmail dot com
Operating system: Linux
PHP version:      Irrelevant
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:get_browser() incorrectly parsers entries with "+" sign.

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 bug report at https://bugs.php.net/bug.php?id=65550&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65550&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=65550&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=65550&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=65550&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=65550&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=65550&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=65550&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=65550&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=65550&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=65550&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=65550&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=65550&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=65550&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65550&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=65550&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=65550&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=65550&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65550&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=65550&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65550&r=mysqlcfg

Reply via email to