[BUGFIX] Form email validation is case sensitive 24/20524/2
authorPatrick Broens <patrick@patrickbroens.nl>
Thu, 2 May 2013 14:22:23 +0000 (16:22 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sun, 5 May 2013 13:41:44 +0000 (15:41 +0200)
Currently the FORM email validation is using a regular expression which
checks the email address. This check also inclused case sensitivity.

This patch fixes this by using the email address validator which comes
with the extension core.

Change-Id: Ib1449198f66f023a01c9791e74eb2d634abd77df
Resolves: #43924
Releases: 6.0, 6.1, 6.2
Reviewed-on: https://review.typo3.org/20524
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/form/Classes/Validation/EmailValidator.php
typo3/sysext/form/Tests/Unit/Validation/EmailValidatorTest.php

index e5ae2ce..0b8f490 100644 (file)
@@ -40,7 +40,7 @@ class EmailValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
        public function isValid() {
                if ($this->requestHandler->has($this->fieldName)) {
                        $value = $this->requestHandler->getByMethod($this->fieldName);
-                       if (!preg_match('/^(?:(?#local-part)(?#quoted)"[^\\"]*"|(?#non-quoted)[a-z0-9&+_-](?:\\.?[a-z0-9&+_-]+)*)@(?:(?#domain)(?#domain-name)[a-z0-9](?:[a-z0-9-]*[a-z0-9])*(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])*)*|(?#ip)(\\[)?(?:[01]?\\d?\\d|2[0-4]\\d|25[0-5])(?:\\.(?:[01]?\\d?\\d|2[0-4]\\d|25[0-5])){3}(?(1)\\]|))$/', $value)) {
+                       if (!\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($value)) {
                                return FALSE;
                        }
                }
index 8926938..0545598 100644 (file)
@@ -25,11 +25,12 @@ namespace TYPO3\CMS\Form\Tests\Unit\Validation;
 ***************************************************************/
 
 /**
- * Test case for class \TYPO3\CMS\Form\Validation\EmailValidator.
+ * Test case
  *
  * @author Andreas Lappe <a.lappe@kuehlhaus.com>
  */
 class EmailValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
+
        /**
         * @var \TYPO3\CMS\Form\Tests\Unit\Validation\Helper
         */
@@ -51,16 +52,16 @@ class EmailValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        public function validEmailProvider() {
                return array(
-                       'a@b.de'               => array('a@b.de'),
-                       'somebody@localhost'   => array('somebody@localhost'),
+                       'a@b.de' => array('a@b.de'),
                        'somebody@mymac.local' => array('somebody@mymac.local')
                );
        }
 
        public function invalidEmailProvider() {
                return array(
-                       'myemail@'           => array('myemail@'),
-                       'myemail'            => array('myemail'),
+                       'myemail@' => array('myemail@'),
+                       'myemail' => array('myemail'),
+                       'somebody@localhost' => array('somebody@localhost'),
                );
        }