php/php-src — pull request #243 by MichaelRushton (2012-12-21 21:48:08+00:00)
Title: Update php_filter_validate_email regex

Updating to more accurate and optimized regex.

a@b format email address also re-allowed as they are valid:

RFC 5321 Section 2.3.5:

A domain name (or often just a "domain") consists of one or more
components, separated by dots if more than one appears. In the case
of a top-level domain used by itself in an email address, a single
string is used without any dots.

...

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.

ac, uz, and ai are all FQDNs, resolving to A RRs. Additionally, ai resolves to MX RRs. This meets the requirements of RFC 5321 (which even explicitly mentions TLD-only domain names).

Additionally, changed the max length from the incorrect 320 to the correct 254.