Re: browscap.ini module error + fix
| From: | Jay Smith | Date: | Mon, 28 Apr 2003 18:23:59 +0000 |
| Subject: | Re: browscap.ini module error + fix | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-1076@lists.php.net to get a copy of this message | ||
Here's the output I'm getting from PHP 4 (without patch) for the user agent
"Mozilla/4.0 (compatible; MSIE 5.5*;*AOL *Win 9x 4.90*)*":
stdClass Object
(
[browser_name_pattern] => Mozilla/4\.0 (compatible; MSIE 5\.5.*;.*AOL
.*Win 9x 4\.90.*).*
[parent] => IE 5.5
[platform] => WinME
[aol] => 1
[browser] => IE
[version] => 5.5
[majorver] => 5
[minorver] => 5
[css] => 2
[frames] => 1
[iframes] => 1
[tables] => 1
[cookies] => 1
[backgroundsounds] => 1
[vbscript] => 1
[javascript] => 1
[javaapplets] => 1
[activexcontrols] => 1
[ak] =>
[sk] =>
[cdf] => 1
[beta] =>
[win16] =>
[crawler] =>
[stripper] =>
[wap] =>
[netclr] =>
)
And current HEAD with the patch:
stdClass Object
(
[browser_name_regex] => ^Mozilla/4\.0 (compatible; MSIE 5\.5.*;.*AOL
.*Win 9x 4\.90.*).*
[browser_name_pattern] => Mozilla/4.0 (compatible; MSIE 5.5*;*AOL *Win
9x 4.90*)*
[parent] => IE 5.5
[platform] => WinME
[aol] => 1
[browser] => IE
[version] => 5.5
[majorver] => 5
[minorver] => 5
[css] => 2
[frames] => 1
[iframes] => 1
[tables] => 1
[cookies] => 1
[backgroundsounds] => 1
[vbscript] => 1
[javascript] => 1
[javaapplets] => 1
[activexcontrols] => 1
[ak] =>
[sk] =>
[cdf] => 1
[beta] =>
[win16] =>
[crawler] =>
[stripper] =>
[wap] =>
[netclr] =>
)
The browser_name_regex is what is actually checked in the function (which is
really just browser_name_pattern from the older version with the extra '^')
and browser_name_pattern is the browscap.ini entry as it actually appears
in the file. That's why I didn't MFH, there was that little change. I don't
know how often browser_name_pattern is actually used in PHP code, probably
not much, but a little change like that might be important to some people.
But if there's no objections, I can MFH and it can go into 4.3.2RC2, I
suppose, and if there's major problems with it, revert it before the final.
Also, note that the prototype has changed slightly. It's now
proto mixed get_browser([string browser_name [, bool return_array]])
If browser_name is called without a string or browser_name is null,
HTTP_USER_AGENT is used as before. The return value is an object by
default, but setting return_array to true returns an array instead.
J
Uwe Schindler wrote:
> OK. I think we should apply your patch to 4.3, too.
>
> At 12:12 28.04.2003 -0400, Jay Smith wrote:
>
>>Before committing this, could you look at the browscap.c version in HEAD?
>>I made similar changes a month or so ago but I didn't MFH because it
>>affected BC a bit. The fix was for a segfault, but I added the '^' thing,
>>too. See browscap.c version 1.69 for the change (1.70 just has the
>>superglobal JIT thing.)
>>
>>I can MFH the changes to 4.3 if there's no objections. I just left it in
>>HEAD because of the minor BC divergance. (Very minor -- I ran a stock 4.3
>>and a modified browscap.c against 200 MB worth of Apache logs and the
>>difference in reported browsers was negligible.)
>>
>>J
>
> The reported browsers are correct, but not complete reported. For example
> Internet Explorer (as I told in my post) is correctly detected (because of
> the [IE x.x] which is in the user agent), but the exact version and
> platform not. And because of this a lot of scripts fail because
> get_browser()->platform is for example undefined. And IE is one of the
> most used browsers...
>
>
> -----
> Uwe Schindler
> Addr 1: Bamberger Str. 24a, D-96049 Bamberg
> Addr 2: Drausnickstr. 153, D-91052 Erlangen
> http://www.thetaphi.de -
> http:///www.schindlers-software.de
> eMails: uwe@thetaphi.de (private); info@schindlers-software.de (company)
> Tel./Fax: +49 700 PCLATEIN (+49 700 72528346)
>
> Schindlers Software - Home of Schindlers PC-LATEIN 3.10
> DIE Software zum Lateinlernen!