Dojo mission: fix email validation

Events happening in the community are now at Drupal community events on www.drupal.org.
You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!

According to the quality and control team working on a big Drupal project, the function valid_email_address in includes/common.inc fails some very standard email validation tests. I thought that this might be an interesting dojo project as it is a straight forward task that can potentially make a nice core contribution.

Here are the tests that were done, and the results:

EMAIL VALIDATIONS

  1. Enter a valid email address in the Email address field. abc@yahoo.com Pass
  2. Enter special characters hyphen (-) and underscore(_) in Email address field . 1. john_victor@yahoo.com 2. john-victor@yahoo.com *Pass*
  3. Enter values in Email address field without "@"symbol abc.yahoo.com Fail
  4. Enter two "@" symbols in Email address field abc@yahoo@com Fail
  5. Enter special characters in Email address field except hyphen (-) and underscore(_) abc$$@yahoo.com *Fail*
  6. Enter two periods(.) consecutively in Email address field abc..cd@yahoo.com Fail
  7. Enter periods(.) before or after @ symbol in Email address field. abc.@yahoo.com Fail
  8. Enter blank spaces in between email address field john victor @yahoo.com Fail
  9. Enter Email address containing an IP address for domain name. joe@[123.124.233.4] Pass
  10. If domain name ends in a two-letter word then host name before the country name should exist. Joe@yahoo.co.us Pass

The steps to this mission are:

  1. Confirm that the Fails really fail, ie produce unwanted results.
  2. Open an issue in the issue queue for D6
  3. Make adjustments to valid_email_address until all 10 pass.

So, is this a Dojo-worthy task?

Comments

Any other cases?

robertdouglass's picture

Does john.doe@example.com pass or fail?

pass!

morphir's picture

of course that should pass. Many ppl have their e-mails "structured" that way(with the dots).

there used to be

bertboerland's picture

there used to be strict filteringin very old drupal versions. but it was stupid. the convention was uid@domain.tld where tld was limited to max 3 letters. then came .info and all failed. then we had root@localhost and in failed then uid@ipv6address and it failed.

some people think there are three things that need to be in email address user, at sign and top level domain. and even they are wrong. uid (implicit @localhost) is valid as well.

so please, dont try to add rules that will work against us in the end. or make a module, but please not core for this.

--

bert boerland

--

bert boerland

completely agree

greggles's picture

I note that the + is missing from this list. I use greg+uniqueid@example.com to keep track of where my address comes/goes. It is a wildcard system provided my many mail servers that sends all greg+something to the greg mailbox. It amazes me when sites do not validate that address because it is perfectly valid.

I agree that some sites might want this so if this does get implemented (and it seems like a nice module to me) then I believe it should be a contrib only feature.

We already have the validation rules that can be used to limit to certain rulesets if you desire - e.g. %@%.% or something similar.

--
Knaddisons Denver Life | mmm Free Range Burritos

Linux Journal Article

bradbanister's picture

There is an excellent article on PHP email validation in the current issue of Linux Journal.

http://www.linuxjournal.com/article/9585

What Happened To...

mpare's picture

I was just checking to see if anything ever became of this quest?

Peace,

Matthew Pare

Pare Technologies
info at paretech dot com
www.paretech.com

Did you figure out how to do something? Document it on Drupal.org!

Peace,

-mpare

Pare Technologies
Drupal Consulting, Themeing, and Module Development
806.781.8324 | 806.733.3025
www.paretech.com

Figure Something Out? Document Your Success!

I'm using drupal 6.6. And

fessio's picture

I'm using drupal 6.6. And the following e-mails pass: w.@c, e.@ca.

tld - test missing

gbuske's picture

Hi,

I think the tld - test is missing (diff - file is attached)... and why it isn't possible to attach diff - files? :-)
pattern in $domain - variable in common.inc ( valid_email_address ) should looks like this: $domain = '(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).[a-zA-Z]{2,6})+';
cu
georg

Thanks buske

sara2309's picture

hai Guys

Thanks For help

its Works

Still i need a guide From you

Subscribing

1kenthomas's picture

+1; //

~kwt