Issue Bug Rejected

#95963EmailValidation does not allow for leading or trailing spaces in email address

cosmoblonde GmbH 11/12/21, 10:59 updated 11/16/21, 10:56

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!

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.