check *every* regex, not just first

This commit is contained in:
Matt Simerson 2015-12-17 10:24:57 -08:00
parent 00343a48ac
commit 965f4fc440
2 changed files with 5 additions and 3 deletions

View File

@ -307,7 +307,9 @@ sub is_in_badhelo {
$host = lc $host; $host = lc $host;
foreach my $bad ($self->qp->config('badhelo')) { foreach my $bad ($self->qp->config('badhelo')) {
if ($bad =~ /[\{\}\[\]\(\)\^\$\|\*\+\?\\\!]/) { # it's a regexp if ($bad =~ /[\{\}\[\]\(\)\^\$\|\*\+\?\\\!]/) { # it's a regexp
return $self->is_regex_match($host, $bad); if ($self->is_regex_match($host, $bad)) {
return $error, "in badhelo";
}
} }
if ($host eq lc $bad) { if ($host eq lc $bad) {
return $error, "in badhelo"; return $error, "in badhelo";

View File

@ -56,11 +56,11 @@ sub test_invalid_localhost {
foreach my $ip ( undef, '', '192.0.99.5' ) { foreach my $ip ( undef, '', '192.0.99.5' ) {
$self->qp->connection->remote_ip(undef); $self->qp->connection->remote_ip(undef);
($err, $why) = $self->invalid_localhost('localhost' ); ($err, $why) = $self->invalid_localhost('localhost' );
ok(!$err, "host: localhost, invalid remote ip"); ok($err, "host: localhost, remote ip ($ip)");
$self->qp->connection->remote_ip(undef); $self->qp->connection->remote_ip(undef);
($err, $why) = $self->invalid_localhost('not-localhost'); ($err, $why) = $self->invalid_localhost('not-localhost');
ok($err, "host: not-localhost, invalid remote ip"); ok(! $err, "host: not-localhost, remote ip ($ip)");
} }
foreach my $ip (qw/ ::1 127.0.0.1 / ) { foreach my $ip (qw/ ::1 127.0.0.1 / ) {