FILTER_VALIDATE_EMAIL without its regular expression.
php_filter_validate_email() matches the address (at most 320 bytes)
against one of two fixed regular expressions (EMAIL, or
EMAIL_UNICODE with FILTER_FLAG_EMAIL_UNICODE). Every part of them
is deterministic except two lookaheads, so this module checks the same
language directly, one character at a time (a byte, or a code point for
the /u expression):
(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){255,})and the same with{65,}@: the units of these lookaheads are a character other than\and", or\and a character up to\x7E, each with an optional"on both sides. Where each unit starts is forced, so the address is refused when 255 units follow each other from the start, or 65 or more are followed by@(units_refuse).- the local part: dot-separated words, each an atom or a quoted string.
- the domain: dot-separated labels of letters, digits and inner hyphens,
none of 64 characters or more, ending in one starting with a letter;
or an address literal (
[IPv4],[IPv6:...]with at most 6 groups around::,[IPv6:...:IPv4]with at most 4).
The expressions are case-insensitive: with /u, PCRE2 also matches K
with U+212A KELVIN SIGN and S with U+017F LATIN SMALL LETTER LONG S, and
\pL/\pN follow PCRE2's Unicode 15.0.0 tables.
The one thing a direct check cannot see is PCRE2 running out of
pcre.backtrack_limit, which fails the validation. Only the lookaheads
backtrack enough to get there, by trying both sides for each " between
two units: an address with more than MAX_QUOTES double quotes runs
the regular expression itself (see validate).