[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Perl Question
One of my CGI scripts has the following code:
# Verify from & to
for my $param ("from", "to")
{
if ($query->param($param) =~
/^\s*(\S+.*?)?\s*<([\w\.\-\%]+\@\[?[A-Za-z0-9\-\.]+\]?)>\s*$/)
{
$name{$param}=$1;
$address{$param}=$2;
}
elsif ($query->param($param) =~
/^\s*([\w\.\-\%]+\@\[?[A-Za-z0-9\-\.]+\]?)\s*(\(\S+.*?\))?\s*$/)
{
$address{$param}=$1;
$name{$param}=$2;
$name{$param}=~s/^\((.*)\)$/$1/;
}
else
{
print "<p>\nPlease enter a valid $param email address.\n</p>\n";
print $query->end_html;
exit 0;
}
}
Hopefully those two regular expressions make some kind of sense. Basically
I'm trying to allow any of the following to work:
Steven Pritchard <steve@silug.org>
steve@silug.org (Steven Pritchard)
steve@silug.org
All with leading or trailing whitespace. (Also things like
"foo@[10.0.0.1]" or "foo%bar@example.com", which are valid(-looking)
addresses should work.)
Steve
--
steve@silug.org | Southern Illinois Linux Users Group
(618)398-7320 | See web site for meeting details.
Steven Pritchard | http://www.silug.org/
-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.
- References:
- Perl Question
- From: Matthew Walker <Matthew.Walker@cstonesystems.com>