egulias / EmailValidator

PHP Email address validator
MIT License
11.42k stars 206 forks source link

RE: Emails with no top level domain suffix are coming through as valid #359

Open bretto36 opened 1 year ago

bretto36 commented 1 year ago

I'm using Laravel, which utilizes this library under the hood. I have an email which is coming through as valid but i don't think it should be. I'm not across the current standard oh what constitutes a valid email, but i assume it would need a top level suffix of some sort.

sales@test is the email that comes back as valid

$email = 'sales@test';

        $validator = \Validator::make(['email' => $email], [
            'email' => 'required|email',
        ]);

        try {
            $validator->validate();
        } catch (\Exception $e) {
            dd('invalid');
        }

        dd('valid');
FrazeColder commented 1 year ago

Please take a look at this, I am facing the same issue here!

joleenshook commented 1 year ago

Same issue. If this is expected behavior, please give us a simple way to override it.

MatthieuScarset commented 1 year ago

+1 to have a proper way to override this.

Having the same issue with this library in Drupal.

egulias commented 1 year ago

Hi folks. Apologies for the delay. This is the expected behaviour, as email RFCs do not explicitly state there should be a TLD.

Now, reflecting on this and given that I'm following RFC 1035 for the domain part, it is true it should require to have a TLD.

Will work on this.

nikspyratos commented 11 months ago

I'm not well versed in creating & using lexers, but I'm going to guess the issue lies here as that's the only place $tldMissing is set to false, when it should be true in an example@notld input.