PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Validate » Validate » Bug #2662

Invalid email addresses are validated

Details

Submitted2004-11-01 17:01 UTC
Frommitchenall at gmail dot com
Assigneddufuz
StatusClosed
PackageValidate
PHP VersionIrrelevant
OSAny
Roadmaps0.8.0

Comments

[2004-11-01 17:01 UTC] mitchenall at gmail dot com

Description:
------------
The regex for testing the email address is not correct as it will accept addresses with trailing dots.

Reproduce code:
---------------
In Validate.php, the following changed regex seems to work a little better...

function email($email, $check_domain = false)
{
if($check_domain){

}

if (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.
'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+'.
'(\.[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+)+$', $email))

Note, the 3rd part of the regex now has the '.' from the 2nd part at the beginning of the additional parenthesised block and this block and be repeated one or more times. Also, the dot is removed from the character class in the 3rd block.

Currently, the following tests return true...

if(Validate::email('mark@mitchenall.com.')) {
echo 'valid' ;
} else {
echo 'invalid' ;
}

Expected result:
----------------
invalid

Actual result:
--------------
valid