]> granicus.if.org Git - php/commitdiff
MFB: Bug #44445 (email validator does not handle domains starting/ending
authorIlia Alshanetsky <iliaa@php.net>
Tue, 18 Mar 2008 23:32:42 +0000 (23:32 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 18 Mar 2008 23:32:42 +0000 (23:32 +0000)
with a -)

NEWS
ext/filter/logical_filters.c
ext/filter/tests/bug44445.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index a4668bab47ed171c53cc7deae9707507304695b4..891c0d80035a01b4572314a98dd72f1f5d1ee563 100644 (file)
--- 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)
index b87e57acd71d979365dc90da4226ea442730f403..36317e8311225e37596e5725ce27ee66679c3fe0 100644 (file)
@@ -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 (file)
index 0000000..36a8641
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #44445 (email validator does not handle domains starting/ending with a -)
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+var_dump(filter_var("foo@-foo.com",FILTER_VALIDATE_EMAIL));
+var_dump(filter_var("foo@foo-.com",FILTER_VALIDATE_EMAIL));
+?>
+--EXPECT--     
+bool(false)
+bool(false)