diff --git a/Build.PL b/Build.PL index 73b8a2d..967589e 100644 --- a/Build.PL +++ b/Build.PL @@ -20,7 +20,7 @@ "Olaf Alders (current maintainer)" ], "dist_name" => "HTTP-BrowserDetect", - "dist_version" => "1.62", + "dist_version" => "1.64", "license" => "perl", "module_name" => "HTTP::BrowserDetect", "recommends" => {}, @@ -43,17 +43,21 @@ ); +my %fallback_build_requires = ( + "File::Slurp" => 0, + "FindBin" => 0, + "JSON::PP" => 0, + "Module::Build" => "0.3601", + "Test::FailWarnings" => 0, + "Test::More" => 0, + "Test::Most" => 0, + "Test::NoWarnings" => 0 +); + + unless ( eval { Module::Build->VERSION(0.4004) } ) { - my $tr = delete $module_build_args{test_requires}; - my $br = $module_build_args{build_requires}; - for my $mod ( keys %$tr ) { - if ( exists $br->{$mod} ) { - $br->{$mod} = $tr->{$mod} if $tr->{$mod} > $br->{$mod}; - } - else { - $br->{$mod} = $tr->{$mod}; - } - } + delete $module_build_args{test_requires}; + $module_build_args{build_requires} = \%fallback_build_requires; } my $build = Module::Build->new(%module_build_args); diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 352f6f3..b9fc257 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -16,7 +16,7 @@ * Olaf Alders * Olivier Bilodeau * Paul Findlay - * Robin Smidsrød + * Robin Smidsrød * Ronald J Kimball * Surikov Alexey * Thom Blake diff --git a/Changes b/Changes index 62fd795..56fb6ee 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,11 @@ Revision history for Perl extension HTTP::BrowserDetect. + +1.64 2013-11-25 10:10:23 America/Toronto + - Adds detection for Opera 15+ (Douglas Christopher Wilson) + +1.63 2013-11-21 21:39:46 America/Toronto + - Adds detection for Internet Explorer 11 (Douglas Christopher Wilson) + - Adds detection for Windows 8.1 (Douglas Christopher Wilson) 1.62 2013-10-25 14:40:57 America/Toronto - Returns explicit undef more consistently (David Ihnen) diff --git a/META.json b/META.json index 56e1f4d..8d9d1d6 100644 --- a/META.json +++ b/META.json @@ -6,7 +6,7 @@ "Olaf Alders (current maintainer)" ], "dynamic_config" : 0, - "generated_by" : "Dist::Zilla version 4.300035, CPAN::Meta::Converter version 2.120921", + "generated_by" : "Dist::Zilla version 5.006, CPAN::Meta::Converter version 2.132830", "license" : [ "perl_5" ], @@ -63,7 +63,7 @@ "web" : "https://github.com/oalders/http-browserdetect" } }, - "version" : "1.62", + "version" : "1.64", "x_contributors" : [ "Aran Deltac ", "David Ihnen ", diff --git a/Makefile.PL b/Makefile.PL index d4b9311..a351f9e 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -36,37 +36,32 @@ "Test::Most" => 0, "Test::NoWarnings" => 0 }, - "VERSION" => "1.62", + "VERSION" => "1.64", "test" => { "TESTS" => "t/*.t" } ); +my %FallbackPrereqs = ( + "File::Slurp" => 0, + "FindBin" => 0, + "JSON::PP" => 0, + "Module::Build" => "0.3601", + "Test::FailWarnings" => 0, + "Test::More" => 0, + "Test::Most" => 0, + "Test::NoWarnings" => 0, + "strict" => 0, + "vars" => 0, + "warnings" => 0 +); + + unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { - my $tr = delete $WriteMakefileArgs{TEST_REQUIRES}; - my $br = $WriteMakefileArgs{BUILD_REQUIRES}; - for my $mod ( keys %$tr ) { - if ( exists $br->{$mod} ) { - $br->{$mod} = $tr->{$mod} if $tr->{$mod} > $br->{$mod}; - } - else { - $br->{$mod} = $tr->{$mod}; - } - } -} - -unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { - my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; - my $pp = $WriteMakefileArgs{PREREQ_PM}; - for my $mod ( keys %$br ) { - if ( exists $pp->{$mod} ) { - $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; - } - else { - $pp->{$mod} = $br->{$mod}; - } - } + delete $WriteMakefileArgs{TEST_REQUIRES}; + delete $WriteMakefileArgs{BUILD_REQUIRES}; + $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} diff --git a/README b/README index b62d848..75d2db0 100644 --- a/README +++ b/README @@ -3,7 +3,7 @@ an HTTP user agent string VERSION - version 1.62 + version 1.64 SYNOPSIS use HTTP::BrowserDetect; @@ -182,7 +182,9 @@ win32 winme win95 win98 winnt - win2k winxp win2k3 winvista win7 win8 + win2k winxp win2k3 winvista win7 + win8 + win8_0 win8_1 wince winphone winphone7 winphone7_5 winphone8 @@ -212,7 +214,7 @@ solely for compatibility with the HTTP::Headers::UserAgent module. Win95, Win98, WinNT, Win2K, WinXP, Win2k3, WinVista, Win7, Win8, - Windows Phone, Mac, Mac OS X, iOS, Win3x, OS2, Unix, Linux, + Win8.1, Windows Phone, Mac, Mac OS X, iOS, Win3x, OS2, Unix, Linux, Firefox OS, Playstation 3 GameOS, Playstation Portable GameOS, RIM Tablet OS @@ -228,7 +230,7 @@ firefox gecko icab - ie ie3 ie4 ie4up ie5 ie55 ie6 ie7 ie8 ie9 ie10 + ie ie3 ie4 ie4up ie5 ie55 ie6 ie7 ie8 ie9 ie10 ie11 java konqueror lotusnotes diff --git a/dist.ini b/dist.ini index 54a9c4b..4a91741 100644 --- a/dist.ini +++ b/dist.ini @@ -5,7 +5,7 @@ license = Perl_5 copyright_holder = Lee Semel copyright_year = 2013 -version = 1.62 +version = 1.64 main_module = lib/HTTP/BrowserDetect.pm [GatherDir] diff --git a/lib/HTTP/BrowserDetect.pm b/lib/HTTP/BrowserDetect.pm index 8eef564..cdd6c85 100755 --- a/lib/HTTP/BrowserDetect.pm +++ b/lib/HTTP/BrowserDetect.pm @@ -3,7 +3,7 @@ package HTTP::BrowserDetect; { - $HTTP::BrowserDetect::VERSION = '1.62'; + $HTTP::BrowserDetect::VERSION = '1.64'; } use vars qw(@ALL_TESTS); @@ -22,9 +22,9 @@ win95 win98 winnt winme win32 win2k winxp win2k3 winvista - win7 win8 wince - winphone winphone7 winphone7_5 - winphone8 + win7 win8 win8_0 + win8_1 wince winphone + winphone7 winphone7_5 winphone8 ); # More precise Mac @@ -89,6 +89,7 @@ ie5 ie5up ie55 ie55up ie6 ie7 ie8 ie9 ie10 + ie11 ); our @OPERA_TESTS = qw( @@ -278,6 +279,9 @@ my $ua = lc $self->{user_agent}; + # Trident Engine (detect early for sniffing out IE) + $tests->{TRIDENT} = ( index( $ua, "trident/" ) != -1 ); + # Browser version my ( $major, $minor, $beta ) = ( $ua =~ m{ @@ -323,15 +327,47 @@ ( $major, $minor, $beta ) = split /\./, $1; } + elsif ($tests->{TRIDENT} && $ua =~ m{\b rv: ( [0-9\.]+ ) \b}x ) { + # MSIE masking as Gecko really well ;) + ( $major, $minor, $beta ) = split /\./, $1; + } + + # Opera browsers + + $tests->{OPERA} + = ( index( $ua, "opera" ) != -1 + || index( $ua, "opr/" ) != -1 ); + $tests->{OPERA3} + = ( index( $ua, "opera 3" ) != -1 + || index( $ua, "opera/3" ) != -1 ); + $tests->{OPERA4} + = ( index( $ua, "opera 4" ) != -1 ) + || ( index( $ua, "opera/4" ) != -1 + && ( index( $ua, "nintendo dsi" ) == -1 ) ); + $tests->{OPERA5} + = ( index( $ua, "opera 5" ) != -1 ) + || ( index( $ua, "opera/5" ) != -1 ); + $tests->{OPERA6} + = ( index( $ua, "opera 6" ) != -1 ) + || ( index( $ua, "opera/6" ) != -1 ); + $tests->{OPERA7} + = ( index( $ua, "opera 7" ) != -1 ) + || ( index( $ua, "opera/7" ) != -1 ); # Opera needs to be dealt with specifically # http://dev.opera.com/articles/view/opera-ua-string-changes/ + # http://my.opera.com/community/openweb/idopera/ # Opera/9.80 (S60; SymbOS; Opera Mobi/320; U; sv) Presto/2.4.15 Version/10.00 + # Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 OPR/15.0.1147.100 if ( $ua =~ m{\AOpera.*\sVersion/(\d*)\.(\d*)\z}i ) { $major = $1; $minor = $2; } + elsif ( $ua =~ m{\bOPR/(\d+)\.(\d+)}i ) { + $major = $1; + $minor = $2; + } elsif ( $ua =~ m{NetFront/(\d*)\.(\d*) Kindle}i ) { $major = $1; $minor = $2; @@ -349,7 +385,9 @@ $tests->{GECKO} = ( index( $ua, "gecko" ) != -1 ) && ( index( $ua, "like gecko" ) == -1 ); - $tests->{CHROME} = ( index( $ua, "chrome/" ) != -1 ); + $tests->{CHROME} + = ( !$tests->{OPERA} + && index( $ua, "chrome/" ) != -1 ); $tests->{SAFARI} = ( ( index( $ua, "safari" ) != -1 ) || ( index( $ua, "applewebkit" ) != -1 ) ) @@ -398,11 +436,12 @@ = ( !$tests->{FIREFOX} && !$tests->{SAFARI} && !$tests->{CHROME} + && !$tests->{OPERA} + && !$tests->{TRIDENT} && index( $ua, "mozilla" ) != -1 && index( $ua, "msie" ) == -1 && index( $ua, "spoofer" ) == -1 && index( $ua, "compatible" ) == -1 - && index( $ua, "opera" ) == -1 && index( $ua, "webtv" ) == -1 && index( $ua, "hotjava" ) == -1 && index( $ua, "nintendo" ) == -1 @@ -442,7 +481,8 @@ # Internet Explorer browsers - $tests->{IE} = ( index( $ua, "msie" ) != -1 + $tests->{IE} = ( $tests->{TRIDENT} + || index( $ua, "msie" ) != -1 || index( $ua, 'microsoft internet explorer' ) != -1 ); $tests->{IE3} = ( $tests->{IE} && $major == 3 ); $tests->{IE4} = ( $tests->{IE} && $major == 4 ); @@ -457,6 +497,7 @@ $tests->{IE8} = ( $tests->{IE} && $major == 8 ); $tests->{IE9} = ( $tests->{IE} && $major == 9 ); $tests->{IE10} = ( $tests->{IE} && $major == 10 ); + $tests->{IE11} = ( $tests->{IE} && $major == 11 ); # Neoplanet browsers @@ -475,21 +516,6 @@ $tests->{AOL6} = ( index( $ua, "aol 6.0" ) != -1 ); $tests->{AOLTV} = ( index( $ua, "navio" ) != -1 ) || ( index( $ua, "navio_aoltv" ) != -1 ); - - # Opera browsers - - $tests->{OPERA} = ( index( $ua, "opera" ) != -1 ); - $tests->{OPERA3} = ( index( $ua, "opera 3" ) != -1 ) - || ( index( $ua, "opera/3" ) != -1 ); - $tests->{OPERA4} = ( index( $ua, "opera 4" ) != -1 ) - || ( index( $ua, "opera/4" ) != -1 - && ( index( $ua, "nintendo dsi" ) == -1 ) ); - $tests->{OPERA5} = ( index( $ua, "opera 5" ) != -1 ) - || ( index( $ua, "opera/5" ) != -1 ); - $tests->{OPERA6} = ( index( $ua, "opera 6" ) != -1 ) - || ( index( $ua, "opera/6" ) != -1 ); - $tests->{OPERA7} = ( index( $ua, "opera 7" ) != -1 ) - || ( index( $ua, "opera/7" ) != -1 ); # Other browsers @@ -653,8 +679,6 @@ # Engines - $tests->{TRIDENT} = ( index( $ua, "trident/" ) != -1 ); - $self->{engine_version} = $self->{gecko_version}; if ( $ua =~ /trident\/([\w\.\d]*)/ ) { @@ -838,7 +862,9 @@ $tests->{WIN2K3} = ( index( $ua, "nt 5.2" ) != -1 ); $tests->{WINVISTA} = ( index( $ua, "nt 6.0" ) != -1 ); $tests->{WIN7} = ( index( $ua, "nt 6.1" ) != -1 ); - $tests->{WIN8} = ( index( $ua, "nt 6.2" ) != -1 ); + $tests->{WIN8_0} = ( index( $ua, "nt 6.2" ) != -1 ); + $tests->{WIN8_1} = ( index( $ua, "nt 6.3" ) != -1 ); + $tests->{WIN8} = ( $tests->{WIN8_0} || $tests->{WIN8_1} ); $tests->{DOTNET} = ( index( $ua, ".net clr" ) != -1 ); $tests->{WINME} = ( index( $ua, "win 9x 4.90" ) != -1 ); # whatever @@ -1050,7 +1076,8 @@ return 'Win2k3' if $self->win2k3; return 'WinVista' if $self->winvista; return 'Win7' if $self->win7; - return 'Win8' if $self->win8; + return 'Win8' if $self->win8_0; + return 'Win8.1' if $self->win8_1; return 'WinNT' if $self->winnt; return 'Windows Phone' if $self->winphone; return 'Win3x' if $self->win3x; @@ -1453,7 +1480,7 @@ =head1 VERSION -version 1.62 +version 1.64 =head1 SYNOPSIS @@ -1650,7 +1677,9 @@ win32 winme win95 win98 winnt - win2k winxp win2k3 winvista win7 win8 + win2k winxp win2k3 winvista win7 + win8 + win8_0 win8_1 wince winphone winphone7 winphone7_5 winphone8 @@ -1691,7 +1720,7 @@ compatibility with the L module. Win95, Win98, WinNT, Win2K, WinXP, Win2k3, WinVista, Win7, Win8, - Windows Phone, Mac, Mac OS X, iOS, Win3x, OS2, Unix, Linux, + Win8.1, Windows Phone, Mac, Mac OS X, iOS, Win3x, OS2, Unix, Linux, Firefox OS, Playstation 3 GameOS, Playstation Portable GameOS, RIM Tablet OS @@ -1715,7 +1744,7 @@ =head3 icab -=head3 ie ie3 ie4 ie4up ie5 ie55 ie6 ie7 ie8 ie9 ie10 +=head3 ie ie3 ie4 ie4up ie5 ie55 ie6 ie7 ie8 ie9 ie10 ie11 =head3 java diff --git a/t/useragents.json b/t/useragents.json index 8b3701b..f8dbded 100644 --- a/t/useragents.json +++ b/t/useragents.json @@ -1102,6 +1102,7 @@ "trident", "win32", "win8", + "win8_0", "windows", "winnt" ], @@ -1121,6 +1122,7 @@ "match" : [ "windows", "win8", + "win8_0", "winnt", "win32", "trident", @@ -1139,6 +1141,73 @@ "engine_minor" : "0", "engine_version" : "6.0", "engine_string" : "Trident" + }, + "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko": { + "browser_string": "MSIE", + "major" : "11", + "match" : [ + "windows", + "win7", + "winnt", + "win32", + "trident", + "ie", + "ie11", + "ie55up", + "ie5up", + "ie4up" + ], + "minor" : "0", + "no_match" : null, + "os_string" : "Win7", + "other" : null, + "version" : "11.0", + "engine_major" : "7", + "engine_minor" : "0", + "engine_version" : "7.0", + "engine_string" : "Trident" + }, + "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko": { + "browser_string": "MSIE", + "major" : "11", + "match" : [ + "windows", + "win8", + "win8_1", + "winnt", + "win32", + "trident", + "ie", + "ie11", + "ie55up", + "ie5up", + "ie4up" + ], + "minor" : "0", + "no_match" : null, + "os_string" : "Win8.1", + "other" : null, + "version" : "11.0", + "engine_major" : "7", + "engine_minor" : "0", + "engine_version" : "7.0", + "engine_string" : "Trident" + }, + "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 OPR/15.0.1147.100" : { + "browser_string" : "Opera", + "major" : "15", + "match" : [ + "windows", + "win7", + "winnt", + "win32", + "opera" + ], + "minor" : "0", + "no_match" : null, + "os_string" : "Win7", + "other" : null, + "version" : "15.0" }, "Mozilla/4.0 (compatible; Opera/3.0; Windows 4.10) 3.50" : { "browser_string" : "Opera",