Commits

Burak Gürsoy  committed 18195f7

Fix RT#72159. This also uncovered another minor bug.

  • Participants
  • Parent commits aac6c87
  • Tags v0.32

Comments (0)

Files changed (4)

 Revision history for Perl extension Parse::HTTP::UserAgent
 
-0.32 Sun Oct 30 01:52:48 2011
+0.32 Sun Nov  6 00:55:40 2011
    => Internal cleanup.
+   => Fixed RT#72159 (Arsen Shirokov).
 
 0.31 Sat Oct 29 19:47:01 2011
    => Version parsing fix for RT#71999.

File lib/Parse/HTTP/UserAgent/Base/Parsers.pm

                             :         'Safari';
     $self->[UA_VERSION_RAW] = $vx;
     $self->[UA_TOOLKIT]     = $extra ? [ split RE_SLASH, $extra->[0] ] : [];
-    $self->[UA_LANG]        = pop @{ $thing };
+    if ( $thing->[-1] && length($thing->[LAST_ELEMENT]) <= 5 ) {
+        # todo: $self->_is_lang_field($junk)
+        # in here or in _post_parse()
+        $self->[UA_LANG]    = pop @{ $thing };
+    }
     $self->[UA_OS]          = @{$thing} && length $thing->[LAST_ELEMENT] > 1
                             ? pop   @{ $thing }
                             : shift @{ $thing }
     }
     $self->[UA_EXTRAS]      = [ @{$thing}, @others ];
 
-    if ( length($self->[UA_OS]) == 1 ) {
-        push @{$self->[UA_EXTRAS]}, $self->[UA_EXTRAS];
+    if ( $self->[UA_OS] && length($self->[UA_OS]) == 1 ) {
+        push @{$self->[UA_EXTRAS]}, $self->[UA_OS];
         $self->[UA_OS] = undef;
     }
 

File t/data/desktop/chrome/1

 
 parser      => 'chrome',
 os          => 'Intel Mac OS X 10_7_1',
-extras      => [ 'KHTML, like Gecko' ],
+extras      => [ 'Macintosh', 'KHTML, like Gecko' ],
 toolkit     => [ 'AppleWebKit', '535.2', '535.200' ],
 version_raw => '15.0.874.54',
 version     => '15.000874054',
 
 'parser'      => 'chrome',
 'os'          => 'Intel Mac OS X 10_6_8',
-'extras'      => ['KHTML, like Gecko'],
+'extras'      => ['Macintosh','KHTML, like Gecko'],
 'toolkit'     => ['AppleWebKit','535.1','535.100'],
 'version_raw' => '14.0.835.202',
 'version'     => '14.000835202',
 'name'        => 'Chrome',
+
+[AGENT]
+
+Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2
+
+extras      => [ 'KHTML, like Gecko' ],
+name        => 'Chrome',
+os          => 'Windows XP',
+parser      => 'chrome',
+toolkit     => [ 'AppleWebKit', '535.2', '535.200' ],
+version     => '15.000874106',
+version_raw => '15.0.874.106',

File t/data/desktop/safari/1

 
 'parser'      => 'safari',
 'os'          => 'Intel Mac OS X 10_6_8',
-'extras'      => ['KHTML, like Gecko', 'Safari/534.51.22'],
+'extras'      => ['Macintosh','KHTML, like Gecko', 'Safari/534.51.22'],
 'toolkit'     => ['AppleWebKit','534.51.22','534.051022'],
 'version_raw' => '5.1.1',
 'version'     => '5.001001',