Skip to content

Commit

Permalink
Revert recent RobotUA changes until fully baked
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christensen committed Jan 18, 2017
1 parent df7e3d7 commit 243f663
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 132 deletions.
16 changes: 1 addition & 15 deletions lib/Vend/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ sub global_directives {
['AcrossLocks', 'yesno', 'No'],
['DNSBL', 'array', ''],
['NotRobotUA', 'list_wildcard', ''],
['RobotUA', 'list_robotua', ''],
['RobotUA', 'list_wildcard', ''],
['RobotIP', 'list_wildcard_full', ''],
['RobotHost', 'list_wildcard_full', ''],
['HostnameLookups', 'yesno', 'No'],
Expand Down Expand Up @@ -3850,20 +3850,6 @@ sub parse_array_complete {
$c;
}

sub parse_list_robotua {
my $value = get_wildcard_list(@_,0);
return '' unless length($value);

# set any high-priority "Final" RobotUA based on prefixed "!!"; note that we are setting a global as a side-effect here!
my @always_robots = ($value =~ m/!!(.*?)(?:\||$)/xg);

if (@always_robots) {
$Global::RobotUAFinal = do { for (join '|' => @always_robots) { qr/$_/ } };
}

return qr/$value/i;
}

sub parse_list_wildcard {
my $value = get_wildcard_list(@_,0);
return '' unless length($value);
Expand Down
35 changes: 11 additions & 24 deletions lib/Vend/Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -279,19 +279,10 @@ EOF
#::logDebug("request_method=$CGI::request_method");
#::logDebug("content_type=$CGI::content_type");

$Vend::Robot = check_is_robot();

$CGI::values{mv_tmp_session} ||= 1 if $Vend::Robot;
}


sub check_is_robot {
my $ret = 1;

#::logDebug("Check robot UA=$Global::RobotUA IP=$Global::RobotIP");
if ($Global::RobotIP and $CGI::remote_addr =~ $Global::RobotIP) {
#::logDebug("It is a robot by IP!");
$ret = 1;
$Vend::Robot = 1;
}
elsif ($Global::HostnameLookups && $Global::RobotHost) {
if (!$CGI::remote_host && $CGI::remote_addr) {
Expand All @@ -300,24 +291,20 @@ sub check_is_robot {
}
if ($CGI::remote_host && $CGI::remote_host =~ $Global::RobotHost) {
#::logDebug("It is a robot by host!");
$ret = 1;
$Vend::Robot = 1;
}
}
if ($Global::RobotUAFinal and $CGI::useragent =~ $Global::RobotUAFinal) {
$ret = 1;
}
else {
unless ($Vend::Robot) {
if ($Global::NotRobotUA and $CGI::useragent =~ $Global::NotRobotUA) {
# do nothing
}
elsif ($Global::RobotUA and $CGI::useragent =~ $Global::RobotUA) {
#::logDebug("It is a robot by UA!");
$ret = 1;
}
unless ($Vend::Robot) {
if ($Global::NotRobotUA and $CGI::useragent =~ $Global::NotRobotUA) {
# do nothing
}
elsif ($Global::RobotUA and $CGI::useragent =~ $Global::RobotUA) {
#::logDebug("It is a robot by UA!");
$Vend::Robot = 1;
}
}
return $ret;

$CGI::values{mv_tmp_session} ||= 1 if $Vend::Robot;
}

# This is called by parse_multipart
Expand Down
91 changes: 0 additions & 91 deletions t/robot_ua.t

This file was deleted.

1 change: 0 additions & 1 deletion t/robot_ua/ua.norobot

This file was deleted.

1 change: 0 additions & 1 deletion t/robot_ua/ua.robot

This file was deleted.

0 comments on commit 243f663

Please sign in to comment.