Subject: | Regexp error |
Mail-CheckUser-1.16
This is perl, v5.8.0 built for i586-linux
Linux rodger-linux 2.4.7-10 #1 Thu Sep 6 17:21:28 EDT 2001 i586 unknown
The REs for name and host don't work. Valid email addresses were rejected with 'bad username syntax'. I suggest replacing the RE code with
(sorry, not a patch) -
# build hostname regexp
# NOTE: it doesn't strictly follow RFC822
# because of what registrars now allow.
my $DOMAIN_RE = qr/(?:[\da-zA-Z]+ -+)* [\da-zA-Z]+/x;
my $HOSTNAME_RE = qr/^ (?:$DOMAIN_RE \.)+ [a-zA-Z]+ $/x;
sub check_hostname_syntax($) {
my($hostname) = @_;
_pm_log "check_hostname_syntax: checking \"$hostname\"";
# check if hostname syntax is correct
if($hostname =~ $HOSTNAME_RE) {
return _result(CU_OK, 'correct hostname syntax');
} else {
return _result(CU_BAD_SYNTAX, 'bad hostname syntax');
}
}
# build username regexp
# NOTE: it doesn't strictly follow RFC821
my $STRING_RE = ('[' . quotemeta(join '',
grep(!/[<>()\[\]\\\.,;:\@"]/, # ["], UnBug
Emacs
map chr, 33 .. 126)) . ']');
my $USERNAME_RE = qr/^ (?:$STRING_RE+ \.)* $STRING_RE+ $/x;
sub check_username_syntax($) {
my($username) = @_;
_pm_log "check_username_syntax: checking \"$username\"";
# check if username syntax is correct
if($username =~ $USERNAME_RE) {
return _result(CU_OK, 'correct username syntax');
} else {
return _result(CU_BAD_SYNTAX, 'bad username syntax');
}
}