Skip Menu |
 

This queue is for tickets about the Parse-HTTP-UserAgent CPAN distribution.

Report information
The Basics
Id: 71795
Status: open
Priority: 0/
Queue: Parse-HTTP-UserAgent

People
Owner: Nobody in particular
Requestors: NEILB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.21
Fixed in: (no value)



Subject: version('raw') vs original_version()
For some browsers, the module doesn't successfully parse the version string, and calling version() will return the wrong thing. Sometimes you need to call $ua->version('raw') to get the raw version string, and sometimes original_version() is the right thing. For example, with Chrome, UA string of 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.54 Safari/535.2' version = 15.000874054 raw version = 15.0.874.54 original version = with opera mini, UA string of Opera/9.80 (Series 60; Opera Mini/6.1.25759/25.872; U; en) Presto/2.5.25 Version/10.54 version = 10.540 raw version = 10.54 original version = 6.1.25759/25.872 Ok, so the UA string is a mess, but apparently the correct version is "6.1.25759", which none of the 3 options returns. Multiple bugs here :-) (1) the 'raw' argument to version() isn't documented (found it looking at the code). (2) difference between version(), version('raw') and original_version() not documented. (3) not clear what the interpretation of each should be anyway.
Download (untitled) / with headers
text/plain 3.2k
19 Eki 2011 Çrş, 19:28:56 tarihinde, NEILB yazdı: Show quoted text
> For some browsers, the module doesn't successfully parse the version > string, > and calling version() will return the wrong thing.
There is a difference between not able to parse at all and wrong parsing :) Former is in SYNOPSIS. See die "Unable to parse!" if $ua->unknown; part Show quoted text
> Sometimes you need to call $ua->version('raw') to get the raw version > string, > and sometimes original_version() is the right thing. > > For example, with Chrome, UA string of > 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_1) AppleWebKit/535.2 > (KHTML, like Gecko) > Chrome/15.0.874.54 Safari/535.2' > version = 15.000874054 > raw version = 15.0.874.54 > original version =
Yes this is parsed as safari and leading to a wrong result. I've added this as a todo item in the code repo. Show quoted text
> with opera mini, UA string of > Opera/9.80 (Series 60; Opera Mini/6.1.25759/25.872; U; en) > Presto/2.5.25 Version/10.54 > version = 10.540 > raw version = 10.54 > original version = 6.1.25759/25.872 > Ok, so the UA string is a mess, but apparently the correct version is > "6.1.25759", which none > of the 3 options returns.
Actually original_version() (see below) returns it as this is Opera faking as Opera, you can rely on original version(). "/25.872" is part of the version string. I can cleanup that part if it's Opera Mini though. I'll think about it. Show quoted text
> Multiple bugs here :-) > > (1) the 'raw' argument to version() isn't documented (found it looking > at the code).
Yes, lots of thing are not documented (and some can change too for that reason). Show quoted text
> (2) difference between version(), version('raw') and > original_version() not documented.
Most of the accessors are not documented. This particular accessor can be used to differentiate fakers: Burak:Parse-HTTP-UserAgent burakgursoy$ myperl -Ilib eg/dump.pl 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Maxthon; Win64; x64; Trident/4.0)' Show quoted text
-------------- PRE PARSE DUMP -------------- FIELD VALUE ----------------- ---------------------------------- extra moz Mozilla/4.0 others thing ['compatible','MSIE 8.0','Windows NT 6.1','Maxthon','Win64','x64','Trident/4.0'] -------------------------------------------- FIELD VALUE ------------------- -------------------------------------- UA_DEVICE UA_DOTNET UA_EXTRAS ['Win64','x64'] UA_GENERIC UA_LANG UA_MOBILE UA_MOZILLA UA_NAME MSIE UA_ORIGINAL_NAME Maxthon UA_ORIGINAL_VERSION 1.0 UA_OS Windows 7 UA_PARSER maxthon UA_ROBOT UA_STRENGTH UA_STRING Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Maxthon; Win64; x64; Trident/4.0) UA_TOOLKIT ['Trident','4.0','4.000'] UA_UNKNOWN UA_VERSION 8.000 UA_VERSION_RAW 8.0 UA_WAP Burak:Parse-HTTP-UserAgent burakgursoy$ So, with version() you'll get the faked IE version. If you really want to know the Maxthon version the the original value can be checked.
> (3) not clear what the interpretation of each should be anyway.
Indeed, Pod is not complete. But also note the module version number, it's not that mature yet. Thanks, Burak


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.