php-src icon indicating copy to clipboard operation
php-src copied to clipboard

FILTER_VALIDATE_EMAIL allows &

Open stccorp opened this issue 4 years ago • 2 comments

Description

The following code:

$email = "EAS&[email protected]";

if (filter_var($email, FILTER_VALIDATE_EMAIL)) { echo("$email is a valid email address"); } else { echo("$email is not a valid email address"); }

Resulted in this output: EAS&[email protected] is a valid email address

But I expected this output instead: is not a valid email address

PHP Version

PHP 8.0.9

Operating System

Windows

stccorp avatar Apr 19 '22 23:04 stccorp

Ampersands are technically valid.

damianwadley avatar Apr 19 '22 23:04 damianwadley

Ok, thank you, it may be technically valid but not practically valid. weird.

stccorp avatar Apr 20 '22 00:04 stccorp