From 34f0981808b68d831b8ea038996c1694c263f713 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Tue, 18 Mar 2008 23:32:42 +0000 Subject: [PATCH] MFB: Bug #44445 (email validator does not handle domains starting/ending with a -) --- NEWS | 2 ++ ext/filter/logical_filters.c | 2 +- ext/filter/tests/bug44445.phpt | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 ext/filter/tests/bug44445.phpt diff --git a/NEWS b/NEWS index a4668bab47..891c0d8003 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ PHP NEWS - Properly address incomplete multibyte chars inside escapeshellcmd() (Ilia, Stefan Esser) - Fix integer overflow in printf(). (Stas, Maksymilian Aciemowicz) +- Fixed bug #44445 (email validator does not handle domains starting/ending + with a -). (Ilia) - Fixed bug #44440 (st_blocks undefined under BeOS). (Felipe) - Fixed bug #44394 (Last two bytes missing from output). (Felipe) - Fixed bug #44388 (Crash inside exif_read_data() on invalid images) (Ilia) diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index b87e57acd7..36317e8311 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -469,7 +469,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]+\\\")|([\\w\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[\\w\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+)*))@((\\[(((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-z\\-]+))$/D"; + const char regexp[] = "/^((\\\"[^\\\"\\f\\n\\r\\t\\b]+\\\")|([\\w\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[\\w\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+)*))@((\\[(((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\\-]+))$/D"; pcre *re = NULL; pcre_extra *pcre_extra = NULL; diff --git a/ext/filter/tests/bug44445.phpt b/ext/filter/tests/bug44445.phpt new file mode 100644 index 0000000000..36a8641419 --- /dev/null +++ b/ext/filter/tests/bug44445.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #44445 (email validator does not handle domains starting/ending with a -) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +bool(false) +bool(false) -- 2.40.0