cvs: pear /Validate Validate.php
| From: | Helgi �ormar �orbj�rnsson | Date: | Mon, 08 Nov 2004 09:12:28 +0000 |
| Subject: | cvs: pear /Validate Validate.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-25762@lists.php.net to get a copy of this message | ||
dufuz Mon Nov 8 04:12:28 2004 EDT
Modified files:
/pear/Validate Validate.php
Log:
Make the email validation use the same regex as QF email rule does, this fixes #2662
http://cvs.php.net/diff.php/pear/Validate/Validate.php?r1=1.41&r2=1.42&ty=u
Index: pear/Validate/Validate.php
diff -u pear/Validate/Validate.php:1.41 pear/Validate/Validate.php:1.42
--- pear/Validate/Validate.php:1.41 Sun Nov 7 19:41:44 2004
+++ pear/Validate/Validate.php Mon Nov 8 04:12:24 2004
@@ -17,7 +17,7 @@
// | Pierre-Alain Joye <paj@pearfr.org> |
// +----------------------------------------------------------------------+
//
-// $Id: Validate.php,v 1.41 2004/11/08 00:41:44 dufuz Exp $
+// $Id: Validate.php,v 1.42 2004/11/08 09:12:24 dufuz Exp $
//
// Methods for common data validations
//
@@ -81,14 +81,16 @@
*/
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))
- {
+ $regex =
'/^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+'.
+
'(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|'.
+ '(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|'.
+ '([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))'.
+ '\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|'.
+ '(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|'.
+ '([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))'.
+ '\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|'.
+ '((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/';
+ if (preg_match($regex, $email)) {
if ($check_domain && function_exists('checkdnsrr')) {
list (, $domain) = explode('@', $email);
if (checkdnsrr($domain, 'MX') || checkdnsrr($domain, 'A')) {