zend framework - Does PHP's built-in filter_input work correctly? -


i tried php's built-in function: filter_input()

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

output:

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

then tried latest release of zend framework (1.11.3):

$validator = new zend_validate_emailaddress();   if ($validator->isvalid('john.doe.@gmail.com')) {     echo 'ok'; } else {     foreach ($validator->getmessages() $message) {             echo "$message\n";     } } 

output:

'john.doe.' can not matched against dot-atom format
'john.doe.' can not matched against quoted-string format
'john.doe.' no valid local part email address 'john.doe.@gmail.com'

either built-in function should return false or zend method 'ok'.

my hubmle question is:
which 1 right?

http://framework.zend.com/manual/en/zend.validate.set.html doesn't indicate wether they're being rfc-strict or not, lets @ source.

in source, _validatelocalpart() defines ebnf they're matching against:

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

it looks stay strict - local part cannot begin or end dot.

the pattern above same in rfc2822 spec: http://www.ietf.org/rfc/rfc2822.txt - , isvalid docblock in zend/validate/emailaddress.php references using 2822.

so, if want rfc2822 compliant, zend_validate_emailaddress doing right, , likely, filter_input doing out of spec.


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -