Skip to content

Commit

Permalink
Don't warn on fake UA string. Closes #156
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders committed Mar 6, 2019
1 parent 72dfee1 commit b80c473
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 14 deletions.
5 changes: 3 additions & 2 deletions lib/HTTP/BrowserDetect.pm
Expand Up @@ -2040,7 +2040,8 @@ sub _init_version {
$version_tests->{ie_compat_mode}
= ( $version_tests->{ie7}
&& $tests->{trident}
&& $self->{engine_version} + 0 >= 4 );
&& $self->engine_version
&& $self->engine_version >= 4 );
}

if ( $browser_tests->{aol} ) {
Expand Down Expand Up @@ -2755,7 +2756,7 @@ sub engine_version {
}
}

return $self->{engine_version};
return undef;
}

sub engine_major {
Expand Down
21 changes: 21 additions & 0 deletions t/99-warnings.t
@@ -0,0 +1,21 @@
#!/usr/bin/env perl

use strict;
use warnings;

use HTTP::BrowserDetect;
use Test::More;
use Test::FailWarnings;

ok( my $ua = HTTP::BrowserDetect->new(undef), q{undef produces no warnings} );

subtest 'no warnings on fake MSIE' => sub {
my $ua = HTTP::BrowserDetect->new(
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/F3E)');
is( $ua->engine_version, undef, 'undef browser_version' );
is( $ua->engine_major, undef, 'undef engine_major' );
is( $ua->engine_minor, undef, 'undef engine_minor' );
is( $ua->engine_beta, undef, 'undef engine_beta' );
};

done_testing();
12 changes: 0 additions & 12 deletions t/99_blank_ua.t

This file was deleted.

18 changes: 18 additions & 0 deletions t/more-useragents.json
Expand Up @@ -3338,6 +3338,24 @@
"os_string" : "WinVista",
"robot" : null
},
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/F3E)" : {
"engine_beta" : null,
"engine_major" : null,
"engine_minor" : null,
"engine_version" : null,
"match" : [
"ie",
"ie4up",
"ie55up",
"ie5up",
"ie7",
"trident",
"win32",
"windows",
"winnt",
"winvista"
]
},
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; HPDTDF; Tablet PC 2.0; .NET4.0C; .NET4.0E; SE 2.X MetaSr 1.0)" : {
"browser" : "ie",
"browser_major" : "7",
Expand Down

0 comments on commit b80c473

Please sign in to comment.