Skip to content

Commit

Permalink
Added seznambot as a search engine
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Oct 19, 2016
1 parent 607f8ec commit 9f7ceff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Revision history for CGI-Info
Added Travis and Coveralls integration
Mark some SEO scanners as robots
On unknown input, debug what it is
Added seznambot as a search engine

0.59 Tue Apr 12 17:38:03 EDT 2016
Log the IP address of client attempting SQL injection
Expand Down
6 changes: 4 additions & 2 deletions lib/CGI/Info.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1399,9 +1399,11 @@ sub is_search_engine {
$self->{_browser_detect} = HTTP::BrowserDetect->new($agent);
}
}
if($self->{_browser_detect}) {
my $browser = $self->{_browser_detect};
if(my $browser = $self->{_browser_detect}) {
my $is_search = ($browser->google() || $browser->msn() || $browser->baidu() || $browser->altavista() || $browser->yahoo() || $browser->bingbot());
if((!$is_search) && $agent =~ /SeznamBot\//) {
$is_search = 1;
}
if($self->{_cache}) {
$self->{_cache}->set($key, $is_search, '1 day');
}
Expand Down
9 changes: 8 additions & 1 deletion t/is_search.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use strict;
use warnings;
use Test::Most tests => 24;
use Test::Most tests => 27;
use Test::NoWarnings;

BEGIN {
Expand Down Expand Up @@ -68,6 +68,13 @@ SEARCH: {
ok($i->is_search_engine() == 1);
ok($i->browser_type() eq 'search');

$ENV{'REMOTE_ADDR'} = '66.249.73.149';
$ENV{'HTTP_USER_AGENT'} = 'Mozilla/5.0 (compatible; SeznamBot/3.2; +http://napoveda.seznam.cz/en/seznambot-intro/)';

$i = new_ok('CGI::Info');
ok($i->is_search_engine() == 1);
ok($i->browser_type() eq 'search');

$ENV{'HTTP_USER_AGENT'} = 'A nonsense user agent string';
$ENV{'REMOTE_ADDR'} = '212.159.106.41';
$i = new_ok('CGI::Info' => [
Expand Down

0 comments on commit 9f7ceff

Please sign in to comment.