Bug #55560 [Csd]: filter_var($e, FILTER_VALIDATE_EMAIL) won't validate spaces in quoted strings

From: Date: Thu, 01 Sep 2011 18:24:16 +0000
Subject: Bug #55560 [Csd]: filter_var($e, FILTER_VALIDATE_EMAIL) won't validate spaces in quoted strings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-163234@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55560&edit=1 ID: 55560 User updated by: fredgandt at hotmail dot com Reported by: fredgandt at hotmail dot com Summary: filter_var($e, FILTER_VALIDATE_EMAIL) won't validate spaces in quoted strings Status: Closed Type: Bug Package: Mail related Operating System: Windows XP (SP3) PHP Version: 5.3SVN-2011-09-01 (SVN) Block user comment: N Private report: N New Comment: I reread and read some extra, edited and re-edited Wikipedia and now have to suggest reopening this bug report. It seems I was right in the first place: Quoted strings containing spaces should validate (return true). See: http://tools.ietf.org/html/rfc3696#section-3 for confirmation. \ \ \ \ @example.com FALSE incorrect since spaces can exist as slashed doublets "abc def"@example.com FALSE incorrect abc"123@456"xyz@example.com FALSE cannot find regulation stating that it should be invalid. abc"123 456"xyz@example.com FLASE also should be valid (it seems) abc"123"xyz@example.com FALSE also, so not a space issue but that the quotes are not outermost of the local-part abc123xyz@example.c TRUE incorrect \\\\\\\\@example.com FALSE incorrect since backslash can quote itself this should be accepted I think there are a few problems need addressing (pun intended). Previous Comments: ------------------------------------------------------------------------ [2011-09-01 12:04:32] fredgandt at hotmail dot com Really sorry. RFC is hard to read so I relied on Wikipedia (usually very good with this kind of thing). Spaces aren't ever allowed. Not even within quotes. Going to edit Wikipedia now instead of waste your time. Forgive? ;-) ------------------------------------------------------------------------ [2011-09-01 11:38:43] fredgandt at hotmail dot com Description: ------------ --- From manual page: http://www.php.net/filter.filters.validate --- IMPORTANT: I am a learner. Sorry if I am wasting your time. Also GoDaddy don't supply much in the way of detail about what version is running. All I know is that it is 5.3.? I have asked for the rest but am still waiting. Using filter_var($e, FILTER_VALIDATE_EMAIL) where $e is a submitted email address that according to RFC 5321 and Wikipedias clearer to understand interpretation of it should be considered valid, the return can be invalid where spaces are featured within quoted strings. e.g. A-Za-z0-9."?Oooh![what]{fun}|is|!".gladthisisn'tmyaddress@[32.64.128.1] == valid (impressive) "Fred Gandt"@fredgandt.com == invalid Take the space out and "FredGandt"@fredgandt.com == valid I've tested all the most unusual combinations I can think of and FILTER_VALIDATE_EMAIL seems to only fail with spaces being disallowed outright rather than only being disallowed when not enclosed by quotes (as with other otherwise disallowed chars). If my interpretation of RFC 5321 is wrong and spaces are in fact never allowed (even when enclosed by quotes) please forgive my impertinence. Love PHP. Very slick and user friendlyness abounds! Test script: --------------- <html><body><br> <form action="" method="post"> <input type="text" name="email" size="100"> <input type="submit" value="POST"><br><br> <?php $e=$_REQUEST["email"]; $result=filter_var($e, FILTER_VALIDATE_EMAIL); if($result){echo($e."<br><br><b style=\"color:#008800;\">Valid Email Address</b>");} else{echo($e."<br><br><b style=\"color:#ff0000;\">Invalid Email Address</b>");} ?> </form></body></html> Expected result: ---------------- Test script provides form entry field "input type="text"" Fill in "textbox" with email address having a local-part with a quoted string containing spaces. e.g. "Fred Gandt"@fredgandt.com Submit EXPECT: Return (echo) == Valid Actual result: -------------- OBSERVE: Return (echo) == Invalid ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=55560&edit=1

« previous php.bugs (#163234) next »