Paul Warren wrote:
>
> On 17 Jun 2008, at 10:51, Tom Walker wrote:
>> -------- Original-Nachricht --------
>>>
>>> There's only one way to do email validation properly:
>>>
>>> 1. Read the RFC
>>> 2. Implement it.
>>>
>>
>> There is another way...
>>
>> 1. Be aware of the RFC
>> 2. Find someone else who has already done it ;-)
>> 3. Judge it's quality.
>>
>> http://commons.apache.org/validator/apidocs/org/apache/commons/validator/routines/package-summary.html#other.email
>>
>>
>> (
>> http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/EmailValidator.java?revision=658832&view=markup
>> )
>>
>>
>> I would guess that the apache commons implementation is fairly widely
>> used, so has hopefully had lots of testing and bug fixes. Always
>> better than maintaining your own IMO.
>
> Experience has shown that me that that hope is often optimistic, and
> wide use is by no means a guarantee of quality.
>
Indeed. The quality of some code I've looked at in the Commons has been
pretty poor, but generally not as bad as Classpath (or ${deity} forbid,
GNU inetlib, which is "maintained" by my predecessor). For the smaller
or less popular Commons libraries, it's often a good idea to have a poke
around the code before adopting it, as I've been bitten by the
occasional lack of thread safety before.
> The link you provide demonstrates a third way:
>
> 1. Find someone else who has already implemented the RFC accurately
> 2. Modify the code until it works in your preferred language:
>
> /**
> * Recursively remove comments, and replace with a single space.
> The simpler
> * regexps in the Email Addressing FAQ are imperfect - they will
> miss escaped
> * chars in atoms, for example.
> * Derived From Mail::RFC822::Address
> * @param emailStr The email address
> * @return address with comments removed.
> */
> protected String stripComments(String emailStr) {
>
> (To be fair, only that function has been lifted directly from the Perl
> module, the rest of it looks like a fairly accurate implementation based
> on the RFC822 grammar)
>
> Paul
>
Chris Wareham
Senior Software Engineer
Visit London Ltd
6th floor,
2 More London Riverside, London SE1 2RR
Tel: +44 (0)20 7234 5848
Fax: +44 (0)20 7234 5753
www.visitlondon.com
2008 Visit London Awards Save the Date - Thursday 27th November at the spectacular Royal Albert Hall
Please don't print this e-mail unless you really need to.
'Visit London Limited' is registered in England under No.761149;
Registered Office: Visit London, 2 More London Riverside, London SE1 2RR.
Visit London is the official visitor organisation for London. Visit London is partly funded by Partnership, the Mayor's London Development Agency and London Councils.
The information contained in this e-mail is confidential and intended for the named recipient(s) only. If you have received it in error, please notify the sender immediately and then delete the message. If you are not the intended recipient, you must not use, disclose, copy or distribute this email. The views expressed in this e-mail are those of the individual and not of Visit London. We reserve the right to read and monitor any email or attachment entering or leaving our systems without prior notice.