Why does filter_var($email, FILTER_VALIDATE_EMAIL) allow test@test?

前端 未结 4 1797
忘了有多久
忘了有多久 2021-02-08 07:00

I was just setting up the validation for a form in which I decided to try using the filter_var function to check the validity of my email address. I can not find out what filter

4条回答
  •  旧巷少年郎
    2021-02-08 08:01

    The behavior has changed somewhere around April. See bug #49576 and revision 297350.

    That e-mail is indeed invalid, or at least that's what the PHP developers understood. The source carries this notice:

    /*
     * 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.
    

    The changelog mentions this bug fix for PHP 5.3.3 and PHP 5.2.14.

提交回复
热议问题