ZF-10764: Zend_Http_UserAgent returns mobile for most Opera user-agents
Description
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.
Comments
Posted by Jared Ray (jared.ray) on 2010-12-02T11:36:16.000+0000
This patch removes the "oper" prefix from the prefix matching array for Zend_Http_UserAgent_Mobile.
Posted by Jared Ray (jared.ray) on 2011-01-12T11:35:38.000+0000
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.
Posted by Adrian Mester (ilogik) on 2011-01-13T06:53:53.000+0000
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?
Posted by Jared Ray (jared.ray) on 2011-01-13T09:27:07.000+0000
The line that needs to be removed is indeed in my unmodified checkout of the 1.11.2 tag. http://framework.zend.com/svn/framework/…
The patch did make it to trunk however.
Posted by Adrian Mester (ilogik) on 2011-01-13T09:34:42.000+0000
'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?
Posted by Adrian Mester (ilogik) on 2011-02-01T09:01:53.000+0000
Yes, the bug is fixed in 1.11.3, thank you :)
Posted by Adrian Mester (ilogik) on 2011-02-01T09:38:01.000+0000
I spoke too soon, sorry. removing line 115 from Http/UserAgent/Mobile.php seems to solve the problems
Posted by Teodora Marusca (teo) on 2011-02-25T06:46:02.000+0000
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
Posted by Ramon Henrique Ornelas (ramon) on 2011-02-25T08:50:27.000+0000
@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
Posted by Jared Ray (jared.ray) on 2011-03-02T13:59:15.000+0000
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.
Posted by Ramon Henrique Ornelas (ramon) on 2011-04-23T22:52:48.000+0000
Was reverted r23660 in trunk in the r23872.
Posted by Ramon Henrique Ornelas (ramon) on 2011-05-22T15:16:46.000+0000
Merged to branch release 1.11 r24043.