Re: Select all invalid e-mail addresses

From: Steve Atkins <steve(at)blighty(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Select all invalid e-mail addresses
Date: 2005-10-20 19:34:39
Message-ID: 20051020193439.GA32591@gp.word-to-the-wise.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Oct 20, 2005 at 11:52:40AM -0400, Andrew Sullivan wrote:
> On Thu, Oct 20, 2005 at 06:10:40PM +0300, Andrus wrote:
> > >From this thread I got the regular expression
>
> [snipped]
>
> Note that that regular expression, which appears to be validating
> TLDs as well, is incredibly fragile. John Klensin has actually
> written an RFC about this very problem. Among other problems, what
> do you do when a country code ceases to be? (There's a similar
> problem that the naming bodies struggke with from time to time.)
>
> I suggest that if you want to validate TLDs, you pull them off when
> you write the data in your database, and use a lookup table to make
> sure they're valid (you can keep the table up to date regularly by
> checking the official IANA registry for them). At least that way you
> don't have to change a regex every time ICANN decides to add another
> TLD.

You need to maintain the data, certainly. To argue that it must
be in a table to be maintained is, well, wrong. My preference would
be to keep it in a table and regenerate the regex periodically, and
in the application layer I do exactly that, but to try and do that
in a check constraint would be painful. A cleaner approach would
be to have a regex that checks for general syntax and extracts the
TLD, which is then compared to a lookup table, perhaps, but that
adds a lot of complexity for no real benefit.

> (The regex is wrong anyway, I think: it doesn't have .mobi,
> which has been announced although isn't taking registrations yet, and
> it doesn't appear to have arpa, either.)

While there are valid deliverable email addresses in .arpa, you really
don't want to be accepting them from end users...

Cheers,
Steve

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Atkins 2005-10-20 19:37:09 Re: Select all invalid e-mail addresses
Previous Message Zlatko Matić 2005-10-20 19:33:58 Re: versions of oDBC driver