Great Circle Associates Majordomo-Workers
(September 1996)
 

Indexed By Date: [Previous] [Next] Indexed By Thread: [Previous] [Next]

Subject: Email address checking
From: liberte @ ncsa . uiuc . edu (Daniel LaLiberte)
Date: Mon, 9 Sep 96 10:49:49 CDT
To: Ryan Waldron <rew @ traveller . com>
Cc: majordomo-workers @ GreatCircle . COM
In-reply-to: <Pine.A32.3.91.960909083732.34550K-100000@cyclone.traveller.com>
References: <9609090907.aa13210@pcusa01.ecunet.org><Pine.A32.3.91.960909083732.34550K-100000@cyclone.traveller.com>

Here is what I use in HyperNews.  

sub addressOK {
  local ($arg) = @_;
  # This is not quite right since it allows "100%."
  if ($arg =~ m|^[A-Za-z0-9_=+%/\.\-]+[@%][A-Za-z0-9_\.\-]+$|) {
      return $arg;
  }
  return '';
}

I added the support for '%' (in place of '@'?) after someone said they
needed it.  But if is not part of a legal internet address, I'd much
rather remove it.

Ryan Waldron writes:

 > sub is_valid_address {
 >     local ($address) = @_;
 > 
 >     # Blanks are bad
 >     return 0 if (length($address) == 0);

How about whitespace blanks?  m/^\s*$/ would catch those.

 >     # Bogus characters are bad
 >     return 0 if ( $address =~ m/[^a-zA-Z0-9@%!_.-]/ );

'+' is used sometimes, e.g. p+t@awaken.com

 >     # C'mon - give us the whole address
 >     return 0 if ( $address !~ m/.+@.+\..+/ );

Seems to require at least one dot in the domain part.  But
liberte@void is legal here within our organization.

What about ^ and $ for beginning and end of string?  Otherwise,
other bad junk might be included.

--
Daniel LaLiberte (liberte@ncsa.uiuc.edu)
National Center for Supercomputing Applications
http://union.ncsa.uiuc.edu/~liberte/




Follow-Ups:
References:
Indexed By Date Previous: Re: So where's this specification?
From: Sean S Coleman 303-497-5672 <coleman@boulder.nist.gov>
Next: V2.0 & Web Interfaces
From: Sean Kamath <kamath@pogo.WV.TEK.COM>
Indexed By Thread Previous: Re: So where's this specification?
From: Ryan Waldron <rew@traveller.com>
Next: Re: Email address checking
From: Paul Haas <paulh@hamjudo.com>

Google
 
Search Internet Search www.greatcircle.com