gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-10-31 22:07:20 24 4
gpt4 key购买 nike

我刚刚为一个表单设置验证,我决定尝试使用 filter_var 函数来检查我的电子邮件地址的有效性。我无法找出 filter_var 在任何地方实际允许的内容(因为文档非常简单),而且我发现它允许像 test@test 这样的电子邮件地址。域中是否必须有 .com、.net 等?

最佳答案

行为在 4 月左右发生了变化。参见 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 的错误修复。

关于php - 为什么 filter_var($email, FILTER_VALIDATE_EMAIL) 允许 test@test?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3406473/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com