#48718 [Com]: FILTER_VALIDATE_EMAIL does not allow number

[email protected] ("sjoerd-php at linuxonly dot nl")
Newsgroups php.bugs
Message-ID <[email protected]>
 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 = '[email protected]';
+var_dump(filter_var($email, FILTER_VALIDATE_EMAIL));
+?>
+--EXPECT--	
+string(18) "[email protected]"


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.

[email protected] - Failed
[email protected] - Success
[email protected] - Success

Reproduce code:
---------------
echo '<pre>',
var_dump(filter_var('[email protected]',
FILTER_VALIDATE_EMAIL)), '</pre>';

Expected result:
----------------
string(42) "[email protected]"


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


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


-- 
Edit this bug report at http://bugs.php.net/?id=48718&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.