GaretJax / phpbrowscap

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

Unsupported operand types in src/phpbrowscap/Browscap.php on line 356 #48

Open reva2 opened 10 years ago

reva2 commented 10 years ago

Library can't properly handle some user agents strings and show this errors:

PHP Notice:  Undefined index:  in /var/www/vendor/garetjax/phpbrowscap/src/phpbrowscap/Browscap.php on line 355
PHP Fatal error:  Unsupported operand types in /var/www/vendor/garetjax/phpbrowscap/src/phpbrowscap/Browscap.php on line 356

Some samples of user agents strings causing these errors

mozilla/5.0 (windows; u; windows nt 6.1; en-us) applewebkit/534.3 (khtml, like gecko) chrome/6.0.472.33 safari/534.3 se 2.x metasr 1.0
mozilla/5.0 (windows; u; windows nt 5.1; en-us) applewebkit/534.0 (khtml, like gecko) chrome/6.0.408.1 safari/534.0

Tested with latest lite php version of browscap.ini (5020 Jul 29 2013).

This error occurs in phpbrowsecap versions: 2.0b and dev-master.

Please let me know if you need additional details.

reva2 commented 10 years ago

This issue can be related to issue #36.

The same UA string correctly works with standart and full versions of browscap.ini.