php – 为什么filter_var($email,FILTER_VALIDATE_EMAIL)允许test @ test?

前端之家收集整理的这篇文章主要介绍了php – 为什么filter_var($email,FILTER_VALIDATE_EMAIL)允许test @ test?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我只是设置一个表单的验证,我决定尝试使用filter_var函数来检查我的电子邮件地址的有效性.我无法找到什么filter_var实际允许的地方(因为文档很简单),我发现它允许一个电子邮件地址,如test @ test.在域中不必有.com,.net等…
这个行为在四月份左右发生了变化.见 bug #49576revision 297350.

那个电子邮件确实是无效的,至少这是PHP开发人员所理解的.来源提供此通知

/*
 * The regex below is based on a regex by Michael Rushton.
 * However,it is not identical.  I changed it to only consider routeable
 * addresses as valid.  Michael's regex considers a@b a valid address
 * which conflicts with section 2.3.5 of RFC 5321 which states that:
 *
 *   Only resolvable,fully-qualified domain names (FQDNs) are permitted
 *   when domain names are used in SMTP.  In other words,names that can
 *   be resolved to MX RRs or address (i.e.,A or AAAA) RRs (as discussed
 *   in Section 5) are permitted,as are CNAME RRs whose targets can be
 *   resolved,in turn,to MX or address RRs.  Local nicknames or
 *   unqualified names MUST NOT be used.

changelog提到了这个针对PHP 5.3.3和PHP 5.2.14的错误修复.

原文链接:https://www.f2er.com/php/131695.html

猜你在找的PHP相关文章