EmailValidator icon indicating copy to clipboard operation
EmailValidator copied to clipboard

Whitespaces before and after the @ should not be valid

Open torbenfischer opened this issue 4 years ago • 2 comments

Hello,

we are using your RFCValidation (Package version 2.1.25) through the laravel-framework validation and found a problem. Some customers entered their email address with a whitespace before or after the "@" separating the local and domain part. In our opinion this should not be valid according to RFC.

currently

[email protected] -> valid
name @domain.com -> valid
name@ domain.com -> valid
name @ domain.com -> valid

should be

[email protected] -> valid
name @domain.com -> invalid
name@ domain.com -> invalid
name @ domain.com -> invalid

kind regards Torben

torbenfischer avatar Aug 09 '21 12:08 torbenfischer

Hello @torbenfischer As you can see in https://github.com/egulias/EmailValidator/blob/2.1.x/tests/EmailValidator/Validation/RFCValidationTest.php#L243 , that is the expected behaviour. The email is valid, albeit with warnings for a rare option where it might work (like https://github.com/egulias/EmailValidator/blob/2.1.x/tests/EmailValidator/Validation/RFCValidationTest.php#L103). You can use NoRFCWarningsValidation to invalidate these and other cases.

egulias avatar Aug 12 '21 21:08 egulias

Hello @torbenfischer

you can use the "strict" option in laravel:

'email' => 'email:strict'

see https://laravel.com/docs/9.x/validation

bastian-schur avatar Jun 07 '22 09:06 bastian-schur