ID: 48718 Comment by: sjoerd-php at linuxonly dot nl Reported By: glj dot klomp at gmail dot com Status: Assigned Bug Type: Filter related Operating System: * PHP Version: 5.2.10 Assigned To: iliaa New Comment:
Here is another regex for e-mail validation: http://ex-parrot.com/~pdw/Mail-RFC822-Address.html It is hard to get it right, at least with a regex. Previous Comments: ------------------------------------------------------------------------ [2009-07-05 17:11:01] fel...@php.net But now it accepts TLD containing numbers. ------------------------------------------------------------------------ [2009-07-05 16:08:20] il...@php.net This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. ------------------------------------------------------------------------ [2009-07-02 06:32:27] sjoerd-php at linuxonly dot nl 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 = 't...@mail.2php.net'; +var_dump(filter_var($email, FILTER_VALIDATE_EMAIL)); +?> +--EXPECT-- +string(18) "t...@mail.2php.net" ------------------------------------------------------------------------ [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.lastn...@employee.2something.com - Failed firstname.lastn...@employee.something.com - Success firstname.lastn...@2something.com - Success Reproduce code: --------------- echo '<pre>', var_dump(filter_var('firstname.lastn...@employee.2something.com', FILTER_VALIDATE_EMAIL)), '</pre>'; Expected result: ---------------- string(42) "firstname.lastn...@employee.2something.com" Actual result: -------------- bool(false) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48718&edit=1