standardize hostname regex. use latest list of tlds. import constants so we can syntax check

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@914 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Robert Spier 2008-05-19 07:22:51 +00:00 committed by Ask Bjørn Hansen
parent a05b334b44
commit 356ec2f08d

View File

@ -95,6 +95,8 @@ use Net::DNS::Resolver;
use Time::HiRes qw(time); use Time::HiRes qw(time);
use IO::Select; use IO::Select;
use Qpsmtpd::Constants;
use strict; use strict;
use warnings; use warnings;
@ -323,9 +325,13 @@ sub data_handler {
} }
} }
while ($l =~ m{ while ($l =~ m{
([Ww]{3,3}\.[\w\-.]+\.[a-zA-Z]{2,32}| # www.hostname ((?:www\.)? # www?
[a-zA-Z0-9][a-zA-Z0-9\-.]+\. # hostname. ... [a-zA-Z0-9][a-zA-Z0-9\-.]+\. # hostname
(?:com|net|org|biz|info|[a-zA-Z]{2,2}))(?!\w) # (cc)TLD (?:aero|arpa|asia|biz|cat|com|coop| # tld
edu|gov|info|int|jobs|mil|mobi|
museum|name|net|org|pro|tel|travel
com|net|org|biz|info|[a-zA-Z]{2})
)(?!\w)
}gix) { }gix) {
my $host = lc $1; my $host = lc $1;
my @host_domains = split /\./, $host; my @host_domains = split /\./, $host;
@ -352,8 +358,12 @@ sub data_handler {
while ($l =~ m{ while ($l =~ m{
\w{3,16}:/+ # protocol \w{3,16}:/+ # protocol
(?:\S+@)? # user/pass (?:\S+@)? # user/pass
([\w\-.]+\.[a-zA-Z]{2,32}) # hostname [a-zA-Z0-9][a-zA-Z0-9\-.]+\. # hostname
}gx) { (?:aero|arpa|asia|biz|cat|com|coop| # tld
edu|gov|info|int|jobs|mil|mobi|
museum|name|net|org|pro|tel|travel
com|net|org|biz|info|[a-zA-Z]{2})
}gix) {
my $host = lc $1; my $host = lc $1;
my @host_domains = split /\./, $host; my @host_domains = split /\./, $host;
$self->log(LOGDEBUG, "uribl: matched full URI hostname $host"); $self->log(LOGDEBUG, "uribl: matched full URI hostname $host");