GaretJax / phpbrowscap

Standalone replacement for php's native get_browser() function
MIT License
429 stars 69 forks source link

Incorrect parsing of php_browscap.ini file - browsers with numeric patterns are not recognised. #32

Closed quentin389 closed 11 years ago

quentin389 commented 11 years ago

php_browscap.ini has an entry:

[12345]
Parent="Miscellaneous Browsers"
Browser="12345"

Unfortunately, probably due to change in http://www.php.net/manual/en/function.parse-ini-file.php (perhaps "5.2.4 - Keys and section names consisting of numbers are now evaluated as PHP integers"), this key is parsed to:

  [0]=>
  array(2) {
    ["Parent"]=>
    string(22) "Miscellaneous Browsers"
    ["Browser"]=>
    string(5) "12345"
  }

Which means that you loose the preg match pattern and browser "12345" will never be matched correctly.

quentin389 commented 11 years ago

Right, it was a simple error with using array_shift() function that re-enumerates all numeric keys. Which in conjunction with PHP 5.2.4 change in parse_ini_file() created this error. Fixed.