summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2009-07-07 00:44:26 +0000
committerIlia Alshanetsky <iliaa@php.net>2009-07-07 00:44:26 +0000
commit0f4c418b981ad232498c3f2d2591dea5e6365432 (patch)
treebfd4f2412211591d7776c52df9b385504a0e7cb1
parent81de4ca9998df92384abe11ee9238d76c4e6510e (diff)
downloadphp-git-0f4c418b981ad232498c3f2d2591dea5e6365432.tar.gz
MFB: Fixed bug #48808 (FILTER_VALIDATE_EMAIL allows some invalid e-mail
syntaxes)
-rw-r--r--ext/filter/logical_filters.c2
-rw-r--r--ext/filter/tests/016.phpt12
2 files changed, 11 insertions, 3 deletions
diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c
index d12d4b09ba..2b1fb7e436 100644
--- a/ext/filter/logical_filters.c
+++ b/ext/filter/logical_filters.c
@@ -476,7 +476,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_\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*)*))@((\\[(((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/016.phpt b/ext/filter/tests/016.phpt
index 1df034a31d..fbe8f3b3f9 100644
--- a/ext/filter/tests/016.phpt
+++ b/ext/filter/tests/016.phpt
@@ -15,7 +15,11 @@ $values = Array(
'[]()/@example.com',
'QWERTYUIOPASDFGHJKLZXCVBNM@QWERTYUIOPASDFGHJKLZXCVBNM.NET',
'e.x.a.m.p.l.e.@example.com',
-'firstname.lastname@employee.2something.com'
+'firstname.lastname@employee.2something.com',
+'-@foo.com',
+'foo@-.com',
+'foo@bar.123',
+'foo@bar.-'
);
foreach ($values as $value) {
var_dump(filter_var($value, FILTER_VALIDATE_EMAIL));
@@ -35,4 +39,8 @@ bool(false)
string(57) "QWERTYUIOPASDFGHJKLZXCVBNM@QWERTYUIOPASDFGHJKLZXCVBNM.NET"
string(26) "e.x.a.m.p.l.e.@example.com"
string(42) "firstname.lastname@employee.2something.com"
-Done \ No newline at end of file
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+Done