Bug #95963
closedEmailValidation does not allow for leading or trailing spaces in email address
0%
Description
Email validation is - for my understanding - to strict.
When entering an email address into a form field having type "email", the entered data gets validated.
If that email was entered with leading/trailing spaces, validation fails.
Without the validator, email adresses with leading/trailing spaces do not cause any issues when submitting the form. Only the validator chokes.
The validator class itsself does not cause the issue, but the GeneralUtility does.
The following function in TYPO3\CMS\Core\Utility\GeneralUtility compares the email value to its trimmed version and returns false if there is a difference.
/** * Checking syntax of input email address * * @param string $email Input string to evaluate * @return bool Returns TRUE if the $email address (input string) is valid */ public static function validEmail($email) { // Early return in case input is not a string if (!is_string($email)) { return false; } if (trim($email) !== $email) { return false; } $validator = new EmailValidator(); return $validator->isValid($email, new RFCValidation()); }
Can this comparison be removed?
Thanks!
Updated by Georg Ringer about 3 years ago
- Status changed from New to Rejected
Thanks for creating this issue.
We won't plan this as with the whitespace the email address is simply not valid.
I propose to use e.g. JS to trim the values before submitting the form