Is the filter filter filter_input working correctly?

I tried the built-in PHP function: filter_input ()

var_dump(filter_var('john.doe.@gmail.com', FILTER_VALIDATE_EMAIL));

Conclusion:

string (19) "john.doe. @ gmail.com"

Then I tried the latest version of Zend Framework (1.11.3):

$validator = new Zend_Validate_EmailAddress();  
if ($validator->isValid('john.doe.@gmail.com')) {
    echo 'OK';
} else {
    foreach ($validator->getMessages() as $message) {
            echo "$message\n";
    }
}

Conclusion:

'john.doe. cannot be matched to the dot-atom format of
'John Doe.' cannot be matched with the quote type 'John Doe.' is not a valid local part for the email address' john.doe. @ gmail.com '

Either the built-in function should return FALSE, or the Zend "OK" method.

My question is about hubmle:
Which one is correct?

+5
source share
3 answers

http://framework.zend.com/manual/en/zend.validate.set.html , RFC , .

_validateLocalPart() EBNF, :

    // Dot-atom characters are: 1*atext *("." 1*atext)
    // atext: ALPHA / DIGIT / and "!", "#", "$", "%", "&", "'", "*",
    //        "+", "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~"
    if (preg_match('/^[' . $atext . ']+(\x2e+[' . $atext . ']+)*$/', $this->_localPart)) {

, - .

, rfc2822: http://www.ietf.org/rfc/rfc2822.txt - docblock isValid Zend/Validate/EmailAddress. php 2822.

, rfc2822, Zend_Validate_EmailAddress , , , filter_input .

+2

, Zend_Engine RFC ( 3 ). , , , , , @ , , , .

, gmail john.doe. @gmail.com. , RFC , .

SQL-, sql html, , rfc .

, /, , .

, , , zend .

TooLongDidn'tRead; :

  • . ( , , filter_input)
  • , , , .
  • html-escape sql-bind , html sql, -, , .
  • php mail(), , .
+1

It also depends on the version of PHP you have. PHP 5.2.14 and above (and also 5.3) have an updated regular expression (see fixing source code for PHP ). PHP 5.2.13RC2 and below have the old regular expression. See Also Error No. 49576 .

0
source

All Articles