Revert "[TASK] Additional check for valid domain in validEmail()" 83/35683/2
authorSteffen Müller <typo3@t3node.com>
Tue, 30 Dec 2014 23:00:57 +0000 (00:00 +0100)
committerSteffen Müller <typo3@t3node.com>
Tue, 30 Dec 2014 23:02:19 +0000 (00:02 +0100)
Reverts #56771 which introduced brittle feature + tests to validEmail() which were beyond the scope of the function.

This reverts commit 5033a33d7b7ed13f6672db6846ad097b8120315b.

Change-Id: Ib2b25af1e65ac93c4174117dc15f2e27e5466288
Reverts: #56771
Resolves: #64064
Release: master
Reviewed-on: http://review.typo3.org/35683
Reviewed-by: Steffen Müller <typo3@t3node.com>
Tested-by: Steffen Müller <typo3@t3node.com>
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php

index 068796b..166547a 100755 (executable)
@@ -1087,15 +1087,10 @@ class GeneralUtility {
         * expect to get just two parts. So we pop off the domain and then glue the
         * rest together again.
         *
-        * An additional, optional safety check can be done to see if the domain part
-        * has a valid MX record. see #56771 for more details
-        *
         * @param string $email Input string to evaluate
         * @return bool Returns TRUE if the $email address (input string) is valid
-        * @param bool $checkDnsRecordForValidMxEntry if enabled, a lookup on the domain name (type=MX) is done in order to verify the host part of the email address
-        * @return bool Returns TRUE if the $email address (input string) is valid
         */
-       static public function validEmail($email, $checkDnsRecordForValidMxEntry = FALSE) {
+       static public function validEmail($email) {
                // Early return in case input is not a string
                if (!is_string($email)) {
                        return FALSE;
@@ -1110,14 +1105,7 @@ class GeneralUtility {
                if (!preg_match('/^[a-z0-9.\\-]*$/i', $domain)) {
                        $domain = self::idnaEncode($domain);
                }
-
-               $result = (filter_var($user . '@' . $domain, FILTER_VALIDATE_EMAIL) !== FALSE);
-
-               // check if the domain has a valid MX record via a DNS lookup
-               if ($checkDnsRecordForValidMxEntry === TRUE && $result === TRUE) {
-                       $result = checkdnsrr($domain);
-               }
-               return $result;
+               return filter_var($user . '@' . $domain, FILTER_VALIDATE_EMAIL) !== FALSE;
        }
 
        /**
index 5aa0b26..ab9e6cb 100644 (file)
@@ -929,22 +929,6 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        /**
-        * Data provider for valid validEmail's with DNS Check
-        *
-        * @return array Valid email addresses
-        */
-       public function validEmailValidWithDNSCheckDataProvider() {
-               // please take care when adding more addresses to this
-               // provider! Please not add real addresses to prevent
-               // SPAM bots find this addresses.
-               // this array must contain valid domains for the DNS check
-               return array(
-                       'd3dcljkl38c23dasdas@typo3.org' => array('d3dcljkl38c23dasdas@typo3.org'),
-                       'd3dcljkl38c23dasdas@frank-nägler.de' => array('d3dcljkl38c23dasdas@frank-nägler.de')
-               );
-       }
-
-       /**
         * @test
         * @dataProvider validEmailValidDataProvider
         */
@@ -953,14 +937,6 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        /**
-        * @test
-        * @dataProvider validEmailValidWithDNSCheckDataProvider
-        */
-       public function validEmailReturnsTrueForValidMailAddressWithCheckDnsRecordForValidMxEntry($address) {
-               $this->assertTrue(Utility\GeneralUtility::validEmail($address, TRUE));
-       }
-
-       /**
         * Data provider for invalid validEmail's
         *
         * @return array Invalid email addresses
@@ -1009,14 +985,6 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->assertFalse(Utility\GeneralUtility::validEmail($address));
        }
 
-       /**
-        * @test
-        * @dataProvider validEmailInvalidDataProvider
-        */
-       public function validEmailReturnsFalseForInvalidMailAddressWithCheckDnsRecordForValidMxEntry($address) {
-               $this->assertFalse(Utility\GeneralUtility::validEmail($address, TRUE));
-       }
-
        //////////////////////////////////
        // Tests concerning inArray
        //////////////////////////////////