|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-06-29 12:39 UTC] 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)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 08:00:01 2025 UTC |
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"