PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_TreeMenu » Bug #165

User Agent Identification for Opera 7 incorrect

Details

Submitted2003-10-29 19:44 UTC
Fromosdn at headbonk dot com
Assignedrichard
StatusClosed
PackageHTML_TreeMenu
PHP VersionIrrelevant
OSWindows NT 5.0
Roadmaps(Not assigned)

Comments

[2003-10-29 19:44 UTC] osdn at headbonk dot com

Description:
------------
In the file TreeMenu.js, line #666 there is the following code:

var is_opera7 = is_opera && (agt.indexOf("opera 7") != -1);

This fails to identify Opera 7 with every version I've tried - 7.11, 7.20, & 7.21.

Opera 7 sends the following for the user agent string in the versions mentioned above:

Opera/7.xx (Windows NT 5.0; U) [en]

Where xx is the minor revision number.

I suggest changing the line in question to the following:

var is_opera7 = is_opera && (is_major >= 7);

This works for all the versions of Opera 7 that I've tried, and correctly excludes a version of Opera 6 that I tried (not sure of the particular revision, it was at home).

Note that testing this can be tricky with Opera, as it allows the user to choose to spoof the user agent string to look like another browser. Make sure the "Identify As..." is set to "Identify as Opera" (Hit F12) for quick access. This caused me some confusion when tracking down the cause of this.

[2004-11-10 12:56 UTC] mail at marcel-anacker dot de

Your suggestion breaks the correct identification of Opera 7 with "Identify as IE" set.
A combination of both approaches you mentioned works better:

var is_opera7 = (is_opera && (is_major >= 7)) || (agt.indexOf("opera 7") != -1);