Bug #30311

Problems with the validation of a email-address which contains umlauts - t3lib_div.validEmail

Added by David M. over 9 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2011-09-27
Due date:
% Done:

100%

Estimated time:
2.00 h
TYPO3 Version:
4.5
PHP Version:
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

It seems like the t3lib_div.validEmail function returns false negatives, when you use email-addresses with umlauts like admin@schön.at because the FILTER_VALIDATE_EMAIL is too strict. At http://php.net/manual/de/function.filter-var.php#104160 you can see a possible workaround for this, although it would be nicer with a punycode implementation.


Files

class.t3lib_divTest.php (100 KB) class.t3lib_divTest.php Updated Testcases David M., 2011-09-29 14:40
idna_convert.class.php (92.6 KB) idna_convert.class.php Converter Class (IDN) - Credits to Matthias Sommerfeld David M., 2011-09-29 14:40

Related issues

Related to TYPO3 Core - Bug #34627: idna_convert.class not foundClosedGeorg Ringer2012-03-07

Actions
#1

Updated by Markus Klein over 9 years ago

Hi! Can you provide a patch for this?

#2

Updated by Christian Kuhn over 9 years ago

The method is covered by unit tests. A proper patch should include test cases as well.

#3

Updated by David M. over 9 years ago

I noticed the same problem with umlauts in URLs.
My suggestion for the patch would be:

somewhere else:

$IDN = new idna_convert(array('idn_version' => 2008));

for class.t3lib_div:

/**
 * Checking syntax of input email address
 *
 * @param string $email Input string to evaluate
 * @return boolean Returns TRUE if the $email address (input string) is valid
 */
public static function validEmail($email) {
        // enforce maximum length to prevent libpcre recursion crash bug #52929 in PHP
        // fixed in PHP 5.3.4; length restriction per SMTP RFC 2821
    if (strlen($email) > 320) {
        return FALSE;
    }
    return (filter_var($IDN->encode($email), FILTER_VALIDATE_EMAIL) !== FALSE);
}

/**
 * Checks if a given string is a Uniform Resource Locator (URL).
 *
 * @param string $url The URL to be validated
 * @return boolean Whether the given URL is valid
 */
public static function isValidUrl($url) {
    return (filter_var($IDN->encode($url), FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED) !== FALSE);
}

#4

Updated by Peter Niederlag over 9 years ago

  • Status changed from New to Accepted
  • Target version set to 4.6.0
  • Estimated time set to 2.00 h
  • Complexity set to easy

Hi David. Your proposal seems fine to me, could you maybe make this into a patch/review-request?
idna_convert.class.php is already available in typo3/contrib/idna for #14500.

#5

Updated by Chris topher over 9 years ago

  • Target version changed from 4.6.0 to 4.6.1
#6

Updated by Mr. Jenkins over 9 years ago

  • Status changed from Accepted to Under Review

Patch set 1 of change Iaff6d43c54ce4a2567b46acfe449e33b89136f8d has been pushed to the review server.
It is available at http://review.typo3.org/6907

#7

Updated by Chris topher about 9 years ago

  • Target version changed from 4.6.1 to 4.6.2
#8

Updated by Gerrit Code Review about 9 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/6907

#9

Updated by Oliver Klee about 9 years ago

Are you sure that the local part really may contain non-ASCII characters? AFAIK, punycode only applies to the domain part.

#10

Updated by Xavier Perseguers about 9 years ago

  • Target version deleted (4.6.2)
#11

Updated by Gerrit Code Review almost 9 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/6907

#12

Updated by Gerrit Code Review almost 9 years ago

Patch set 1 for branch TYPO3_4-7 has been pushed to the review server.
It is available at http://review.typo3.org/9434

#13

Updated by Gerrit Code Review almost 9 years ago

Patch set 1 for branch TYPO3_4-6 has been pushed to the review server.
It is available at http://review.typo3.org/9435

#14

Updated by Gerrit Code Review almost 9 years ago

Patch set 1 for branch TYPO3_4-5 has been pushed to the review server.
It is available at http://review.typo3.org/9436

#15

Updated by Mario Rimann almost 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#16

Updated by Gerrit Code Review over 8 years ago

  • Status changed from Resolved to Under Review

Patch set 2 for branch TYPO3_4-6 has been pushed to the review server.
It is available at http://review.typo3.org/9435

#17

Updated by Gerrit Code Review over 8 years ago

Patch set 3 for branch TYPO3_4-6 has been pushed to the review server.
It is available at http://review.typo3.org/9435

#18

Updated by Mario Rimann over 8 years ago

  • Status changed from Under Review to Resolved
#19

Updated by Benni Mack over 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF