ZF-10764: Zend_Http_UserAgent returns mobile for most Opera user-agents


Zend_Http_UserAgent returns a device type of "mobile" all Opera user-agents that start with "oper", which is currently how most desktop versions of Opera user-agents are formatted. Since there are already other checks for opera mobile and opera mini, the solution seems pretty simple.

Sample user agent:

Opera/9.80 (Windows NT 6.0; U; fi) Presto/2.2.0 Version/10.00

Line 295 in Zend_Http_UserAgent_Mobile tries to match mobile browsers by prefix of the user-agent.

if (self::userAgentStart($userAgent)) {
    return true;

One of the prefixes that returns a match is "oper", which matches many desktop user-agents of Opera. Simply removing this prefix from the matching array will still match on Opera mobile/mini user-agents, but will correctly not match on desktop versions of Opera.


This patch removes the "oper" prefix from the prefix matching array for Zend_Http_UserAgent_Mobile.

Note that this fix appears to be in the TRUNK subversion, but not in the 11.2 release, although it was mentioned as fixed in the release notes. I have reopened the ticket to make sure this goes out in the next release.

The patch appears to be in 1.11.2 (the line "oper" doesn't appear in Mobile.php, but it doesn't solve the issue. Can someone confirm this?

The line that needs to be removed is indeed in my unmodified checkout of the 1.11.2 tag.…

The patch did make it to trunk however.

'oper' stil is in the $_uaSignatures array. Based on the line numbers in the patch file, it should have been removed from $_uaBegin array. Maybe the patch is wrong?

Yes, the bug is fixed in 1.11.3, thank you :)

I spoke too soon, sorry. removing line 115 from Http/UserAgent/Mobile.php seems to solve the problems

This patch should fix the issue. Two months ago in revision 23660 Ramon added 'oper' string to $_uaSignatures to solve the issue ZF-10983.

If the string 'oper' is in $_uaSignatures, all Opera browsers including desktop will be recognized as mobile.

The 'opera mini' and 'opera mobi' already declared in $_uaSignatures are enought to match mobile user agents

@Teodera and @Adrian

This bug was inserted in the version 1.11.2 r23584 see ZF-10983 only was done merged by me. Later I will look to this issue.

Greetings Ramon

I confirm that revision 23660 re-introduced this bug. Applying both patches should fix the problem. Problem is not fixed in 1.11.3. To be clear: both 'oper' strings should be removed from {{$_uaSignatures}} and {{$_uaBegin}} otherwise desktop versions of Opera will be matched incorrectly.

This is not currently fixed in trunk.

Was reverted r23660 in trunk in the r23872.

Merged to branch release 1.11 r24043.