Project

General

Profile

Actions

Bug #95963

closed

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

Added by cosmoblonde GmbH about 3 years ago. Updated about 3 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2021-11-12
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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!

Actions #1

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

Actions

Also available in: Atom PDF