From: Felipe Pena Date: Sun, 15 Nov 2009 16:53:40 +0000 (+0000) Subject: - Fixed bug #50158 (FILTER_VALIDATE_EMAIL fails with valid addresses containing ... X-Git-Tag: php-5.3.2RC1~232 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b456901f521e14f9dc9ac5cfed13c04e35f20d5;p=php - Fixed bug #50158 (FILTER_VALIDATE_EMAIL fails with valid addresses containing = or ?). (Patch by Pierrick) --- diff --git a/NEWS b/NEWS index e5d1340752..53f4e0f72b 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,8 @@ PHP NEWS (Pierre) - Fixed bug #50174 (Incorrectly matched docComment). (Felipe) +- Fixed bug #50158 (FILTER_VALIDATE_EMAIL fails with valid addresses + containing = or ?). (Pierrick) - Fixed bug #50087 (NSAPI performance improvements). (Uwe Schindler) - Fixed bug #50152 (ReflectionClass::hasProperty behaves like isset() not property_exists). (Felipe) diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index bf3eaff107..2b72de1c2c 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -472,7 +472,7 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ 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_\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*(\\.[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"; + const char regexp[] = "/^((\\\"[^\\\"\\f\\n\\r\\t\\b]+\\\")|([A-Za-z0-9_][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 --git a/ext/filter/tests/bug50158.phpt b/ext/filter/tests/bug50158.phpt new file mode 100644 index 0000000000..4545cb06b0 --- /dev/null +++ b/ext/filter/tests/bug50158.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #50158 (FILTER_VALIDATE_EMAIL fails with valid addresses containing = or ?) +--FILE-- + +--EXPECTF-- +%unicode|string%(21) "test=mail@example.com" +%unicode|string%(21) "test-mail@example.com" +%unicode|string%(21) "test+mail@example.com"