#48718 [Com]: FILTER_VALIDATE_EMAIL does not allow number

From: Date: Thu, 02 Jul 2009 06:32:27 +0000
Subject: #48718 [Com]: FILTER_VALIDATE_EMAIL does not allow number
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-139113@lists.php.net to get a copy of this message
 ID:               48718
 Comment by:       sjoerd-php at linuxonly dot nl
 Reported By:      glj dot klomp at gmail dot com
 Status:           Open
 Bug Type:         Filter related
 Operating System: *
 PHP Version:      5.2.10
 New Comment:

diff -u -r1.1.2.22.2.12 logical_filters.c
--- ext/filter/logical_filters.c	10 Jun 2009 19:01:17
-0000	1.1.2.22.2.12
+++ ext/filter/logical_filters.c	1 Jul 2009 19:01:42 -0000
@@ -472,7 +472,7 @@
 void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 {
 	/* From
http://cvs.php.net/co.php/pear/HTML_QuickForm/QuickForm/Rule/Email.php?r=1.4
*/
-	const char regexp[] =
"/^((\\\"[^\\\"\\f\\n\\r\\t\\b]+\\\")|([A-Za-z0-9_\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\\\|\\{\\}]+(\\.[A-Za-z0-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]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?(\\.(?=[A-Za-z\\-]))?)+[A-Za-z\\-]*))$/D";
+	const char regexp[] =
"/^((\\\"[^\\\"\\f\\n\\r\\t\\b]+\\\")|([A-Za-z0-9_\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\\\|\\{\\}]+(\\.[A-Za-z0-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]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?(\\.(?=[A-Za-z0-9]))?)+[A-Za-z\\-]*))$/D";
 
 	pcre       *re = NULL;
 	pcre_extra *pcre_extra = NULL;
diff -u -N
/home/sjoerd/dev/php/php-5.3.0/ext/filter/tests/bug48718.phpt
ext/filter/tests/bug48718.phpt
---
/home/sjoerd/dev/php/php-5.3.0/ext/filter/tests/bug48718.phpt	1970-01-01
01:00:00.000000000 +0100
+++ ext/filter/tests/bug48718.phpt	2009-07-01 20:54:54.000000000 +0200
@@ -0,0 +1,11 @@
+--TEST--
+bug 48718, FILTER_VALIDATE_EMAIL does not allow number
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+$email = 'test@mail.2php.net';
+var_dump(filter_var($email, FILTER_VALIDATE_EMAIL));
+?>
+--EXPECT--	
+string(18) "test@mail.2php.net"


Previous Comments:
------------------------------------------------------------------------

[2009-06-29 12:39:25] glj dot klomp at gmail dot com

Description:
------------
When supplying the filter_var() function with a domain containing a
number at the front of the domain, and using a subdomain, the filter
fails.

firstname.lastname@employee.2something.com - Failed
firstname.lastname@employee.something.com - Success
firstname.lastname@2something.com - Success

Reproduce code:
---------------
echo '<pre>',
var_dump(filter_var('firstname.lastname@employee.2something.com',
FILTER_VALIDATE_EMAIL)), '</pre>';

Expected result:
----------------
string(42) "firstname.lastname@employee.2something.com"


Actual result:
--------------
bool(false)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48718&edit=1



Thread (6 messages)

« previous php.bugs (#139113) next »