Commits

Burak Gürsoy committed 3ee8aa6

More Fennec fixes

  • Participants
  • Parent commits 9dc0715
  • Tags v0.35

Comments (0)

Files changed (2)

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

     my($self, @args) = @_;
     $self->_parse_mozilla_family( @args );
     my $e = $self->[UA_EXTRAS];
+
     if ( ref $e eq 'ARRAY'
         && @{ $e } > 0
         && index( lc $e->[-1], 'fennec' ) != NO_IMATCH
     ) {
-        my($name, $version) = split RE_SLASH, pop @{ $e };
-        $self->[UA_ORIGINAL_NAME]    = $name;
-        $self->[UA_ORIGINAL_VERSION] = $version;
-        $self->[UA_MOBILE]           = 1;
-        if ( $self->[UA_LANG]
-            && index( $self->[UA_LANG], q{ } ) != NO_IMATCH
-        ) {
-            push @{ $self->[UA_EXTRAS] }, $self->[UA_LANG];
-            $self->[UA_LANG] = undef;
-        }
+        $self->_fix_fennec( $e );
     }
+
     $self->[UA_NAME] = 'Firefox';
+
     return 1;
 }
 
+sub _fix_fennec {
+    my($self, $e) = @_;
+    my($name, $version) = split RE_SLASH, pop @{ $e };
+    $self->[UA_ORIGINAL_NAME]    = $name;
+    $self->[UA_ORIGINAL_VERSION] = $version;
+    $self->[UA_MOBILE]           = 1;
+    return if ! $self->[UA_LANG];
+
+    if ( lc $self->[UA_LANG] eq 'tablet' ) {
+        $self->[UA_TABLET] = 1;
+        $self->[UA_LANG]   = undef;
+    }
+    elsif ( index( $self->[UA_LANG], q{ } ) != NO_IMATCH ) {
+        push @{ $self->[UA_EXTRAS] }, $self->[UA_LANG];
+        $self->[UA_LANG] = undef;
+    }
+    else {
+        # Do nothing
+    }
+
+    return;
+}
+
 sub _parse_safari {
     my($self, $moz, $thing, $extra, @others) = @_;
     my $ipad            = $thing && lc( $thing->[0] || q{} ) eq 'ipad';

File t/data/mobile/firefox

 toolkit          => [ 'Gecko', '20100101', '20100101.000' ],
 version          => '10.000001',
 version_raw      => '10.0.1',
+
+[AGENT]
+
+Mozilla/5.0 (Android; Tablet; rv:10.0.4) Gecko/10.0.4 Firefox/10.0.4 Fennec/10.0.4
+
+mobile           => 1,
+mozilla          => [ '10.0.4', '10.000004' ],
+name             => 'Firefox',
+original_name    => 'Fennec',
+original_version => '10.0.4',
+os               => 'Android',
+parser           => 'firefox',
+tablet           => 1,
+toolkit          => [ 'Gecko', '10.0.4', '10.000004' ],
+version          => '10.000004',
+version_raw      => '10.0.4',