php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27372 parse error loading browscap.ini at apache startup (new parser required)
Submitted: 2004-02-23 17:22 UTC Modified: 2007-09-28 02:10 UTC
Votes:7
Avg. Score:3.9 ± 0.8
Reproduced:5 of 6 (83.3%)
Same Version:2 (40.0%)
Same OS:3 (60.0%)
From: php-bug-27372 at ryandesign dot com Assigned: jani (profile)
Status: Closed Package: *General Issues
PHP Version: 6CVS, 5CVS, 4CVS (2005-08-25) OS: *
Private report: No CVE-ID: None
 [2004-02-23 17:22 UTC] php-bug-27372 at ryandesign dot com
Description:
------------
When Apache starts with a new version of Gary Keith's 
browscap.ini, PHP reports an error:

PHP:  Error parsing /Library/WebServer/browscap.ini on 
line 711

Line 711 reads:

browser=Yahoo! Slurp

Seems PHP's ini-file reading routine does not like the 
bang in the browser name?

Reproduce code:
---------------
Download the 2/23/2004 or later browscap.ini (or download and unpack browscap.zip) from www.garykeith.com.

Configure php.ini to point to this file.

Stop and restart Apache.

Expected result:
----------------
PHP should read in and accept the file without error.

Actual result:
--------------
PHP reports an error during Apache startup.

All browscap.ini entries before line 711 are loaded.

All entries after that are not.

Since browscap.ini is currently 18682 lines long, this 
means most entries are not loaded.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-24 04:25 UTC] sniper@php.net
Placing those values inside double quotes (") would fix it..
But as I guess that's not an option we have to fix the parser..for php.ini, ! is special..

Maybe the best way to fix this is to have separate scanner/parser for browscap.ini..

 [2004-02-24 11:14 UTC] php_bug_27372 at garykeith dot com
Oh, and the reason I cannot delimit certain values with double-quotes is because browscap.dll does not strip out the quotes. If I entered "Yahoo! Slurp" as a browser name then everyone using browscap.ini on IIS would see "Yahoo! Slurp", including the double quotes as the browser name.
 [2004-02-26 18:32 UTC] php_bug_27372 at garykeith dot com
Hi, Derick.

Since there are so many people still using very early versions of 4.3.x I know it will be a very long time before everyone upgrades to 5.* and that means I'll be stuck in the same untenable situation I'm in right now for a very long time.

Kindly remove the link to my website from your documentation page. It's not fair to your users to refer them to a browscap.ini file that does not work in PHP.

~gary.
 [2004-08-31 21:22 UTC] jay@php.net
I posted this on internals but I should probably add it to 
the bug report, too... 
 
A patch for this against HEAD is available at 
 
http://bugs.tutorbuddy.com/download.php/browscap.patch.tar.gz 
 
It contains the new parser (which goes into ext/standard) 
and updates to the makefiles for *ix and win32. I've 
tested the patch on linux and win2k, and I'd like to 
commit to HEAD for inclusion in 5.1. Backporting to 5.0 
would be nice, too, if possible. 
 
J 
 [2004-10-02 21:54 UTC] alexandre at alapetite dot remove dot net
Gary Keith has already (2004-10-02) kindly modified his browscap.ini in order to prevent a specific crash about the Nutch browser. But the browscap parser should anyway include a security: when one assign a parent to the same parent in browscap.ini, there is an infinite loop that should be prevented.

Example in browscap.ini:
[Nutch]
parent=Nutch

Then in a PHP script:
$browser=get_browser('Nutch');

Effect:
Infinite loop that takes 100% CPU forever.
 [2004-10-04 17:05 UTC] jay@php.net
This would have to be caught during module start up, but 
what should be done about it? Have the parser crap out and 
stop processing when this happens, leaving an error 
message in the logs or on stderr or whatever? Spit out a 
warning but continue processing? What assumptions should 
be made about the screwed up entry, should it just be 
discarded? 
 
This should probably be in it's own bug report, btw, this 
is a seperate issue from the original report. (The new 
parser fixes the original bug report, but not this issue, 
which may or may not be fixed, as it's kind of a problem 
with the ini file itself, akin to calling a function with 
infinite recursion...) 
 
J 
 [2007-09-28 02:10 UTC] jani@php.net
This is now fixed in CVS. Now it is possible to use the plain browscap.ini everybody else uses and there is no more need for the "special" quoted version for PHP.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 06:01:29 2024 UTC