>>>>> "BR" == Brock Rozen <brozen@webdreams.com> writes:
BR> If it fails, then it's a bad addr
BR> if ($email =~ /(@.*@)|(\.\.)/ ||
BR> $email !~ /^.+\@[a-zA-Z0-9\-_\.]+\.[a-zA-Z0-9]{2,3}$/)
First off, I'll give you the benefit of the doubt and assume you mean for
this to apply to a mailbox specifier and not a fully commented address.
Even so, this complains about some perfectly legal addresses, anything with
more than one `@' in it, like, say,
"tibbs@home"@hpc.uh.edu
Please, don't try to get into this until you have read RFC821 very
closely. Every time we complain about legal addresses (like with the `/'
problem) we get lots of complaints. There are a lot of bizarre corner
cases, and if you can't provide data that you've taken all of them into
account then the code just isn't safe to use.
The last comparison isn't a terribly bad idea, though, but even then it
disallows the perfectly legal 'tibbs' and 'tibbs@host' (though the later is
already trapped, which also generates complaints from users). I'm not also
absolutely certain that there aren't other legal characters in a hostname.
- J<
Follow-Ups:
References:
|
|