Commit 183e49f5 authored by Florian Mast's avatar Florian Mast Committed by Jan Helke
Browse files

[BUGFIX] EXT:form Validation of email

Validation of email should respect empty value

Resolves: #54534
Releases: master,7.6
Change-Id: I40c865b42fe7960dd7ab85f710df1045cd04adf0
Reviewed-on: https://review.typo3.org/47059


Reviewed-by: Nicole Cordes's avatarNicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes's avatarNicole Cordes <typo3@cordes.co>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Jan Helke's avatarJan Helke <typo3@helke.de>
Tested-by: Jan Helke's avatarJan Helke <typo3@helke.de>
parent 02258e47
......@@ -14,6 +14,11 @@ namespace TYPO3\CMS\Form\Domain\Validator;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class EmailValidator
*/
class EmailValidator extends AbstractValidator
{
/**
......@@ -32,7 +37,11 @@ class EmailValidator extends AbstractValidator
*/
public function isValid($value)
{
if (!\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($value)) {
if (empty($value) || !is_string($value)) {
return;
}
if (!GeneralUtility::validEmail($value)) {
$this->addError(
$this->renderMessage(
$this->options['errorMessage'][0],
......
......@@ -31,7 +31,9 @@ class EmailValidatorTest extends AbstractValidatorTest
{
return array(
'a@b.de' => array('a@b.de'),
'somebody@mymac.local' => array('somebody@mymac.local')
'somebody@mymac.local' => array('somebody@mymac.local'),
'empty value' => array(''),
'unexpected value' => array(array()),
);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment