]> granicus.if.org Git - php/commitdiff
- Fixed bug #50158 (FILTER_VALIDATE_EMAIL fails with valid addresses containing ...
authorFelipe Pena <felipe@php.net>
Sun, 15 Nov 2009 16:53:40 +0000 (16:53 +0000)
committerFelipe Pena <felipe@php.net>
Sun, 15 Nov 2009 16:53:40 +0000 (16:53 +0000)
  (Patch by Pierrick)

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

index 43d387a861d5f807fd96d3911f09b8526571fcab..478481e4e47ed1bd3efc1692013d0dbf5a7e2714 100644 (file)
@@ -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 (file)
index 0000000..4545cb0
--- /dev/null
@@ -0,0 +1,19 @@
+--TEST--
+Bug #50158 (FILTER_VALIDATE_EMAIL fails with valid addresses containing = or ?)
+--FILE--
+<?php
+
+$email_address = "test=mail@example.com";    
+var_dump(filter_var($email_address, FILTER_VALIDATE_EMAIL));    
+                                                                
+$email_address = "test-mail@example.com";    
+var_dump(filter_var($email_address, FILTER_VALIDATE_EMAIL));    
+    
+$email_address = "test+mail@example.com";    
+var_dump(filter_var($email_address, FILTER_VALIDATE_EMAIL));   
+
+?>
+--EXPECTF--
+%unicode|string%(21) "test=mail@example.com"
+%unicode|string%(21) "test-mail@example.com"
+%unicode|string%(21) "test+mail@example.com"