Home » Validate » Validate » Bug #2662
Invalid email addresses are validated
Details
| Submitted | 2004-11-01 17:01 UTC |
|---|---|
| From | mitchenall at gmail dot com |
| Assigned | dufuz |
| Status | Closed |
| Package | Validate |
| PHP Version | Irrelevant |
| OS | Any |
| Roadmaps | 0.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