Hack invalid w3 spec to validate @localhost email
authorAntoine Musso <hashar@users.mediawiki.org>
Fri, 21 Jan 2011 18:01:47 +0000 (18:01 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Fri, 21 Jan 2011 18:01:47 +0000 (18:01 +0000)
commit4868ccbf3d0fa0302f3525a09915d82068bfa098
tree62666e7de70cb7f200c6253b027501e38fa5e073
parent3d556ca2b70fe7ecaa5711def68df862414660d7
Hack invalid w3 spec to validate @localhost email

In r75682, I have implemented a PHP function to validate email address
based on bug 22449.  Siebrand pointed a w3.org specification which I
implemented. The spec is bugged since it requires a domain and a top
level domain!

I could either make the first part optional or alter the second part
to require 0 to x elements.  I choose the later: s/+/*/

Should fix bug 22449 for good.

TESTS:

Added testEmailDoesNotNeedATopLevelDomain:

Made following emails valid:
  user.@localdaomin
  .@localdomain
  user@a

Test output (please add more):
$ php phpunit.php -c suite.xml --filter alidEmail --tap
TAP version 13
ok 1 - UserIsValidEmailAddrTest::testEmailWellKnownUserAtHostDotTldAreValid
ok 2 - UserIsValidEmailAddrTest::testEmailWithUpperCaseCharactersAreValid
ok 3 - UserIsValidEmailAddrTest::testEmailWithAPlusInUserName
ok 4 - UserIsValidEmailAddrTest::testEmailDoesNotNeedATopLevelDomain
ok 5 - UserIsValidEmailAddrTest::testEmailWithWhiteSpacesBeforeOrAfterAreInvalids
ok 6 - UserIsValidEmailAddrTest::testEmailWithWhiteSpacesAreInvalids
ok 7 - UserIsValidEmailAddrTest::testEmailDomainCanNotBeginWithDot
ok 8 - UserIsValidEmailAddrTest::testEmailWithFunnyCharacters
ok 9 - UserIsValidEmailAddrTest::testEmailTopLevelDomainCanBeNumerical
ok 10 - UserIsValidEmailAddrTest::testEmailWithoutAtSignIsInvalid
ok 11 - UserIsValidEmailAddrTest::testEmailWithOneCharacterDomainIsValid
1..11
includes/User.php
tests/phpunit/includes/UserIsValidEmailAddrTest.php