Project

General

Profile

Actions

Bug #30311

closed

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

Added by David M. about 13 years ago. Updated about 6 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 1 (0 open1 closed)

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

Actions
Actions #1

Updated by Markus Klein about 13 years ago

Hi! Can you provide a patch for this?

Actions #2

Updated by Christian Kuhn about 13 years ago

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

Updated by David M. about 13 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);
}

Actions #4

Updated by Peter Niederlag about 13 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.

Actions #5

Updated by Chris topher about 13 years ago

  • Target version changed from 4.6.0 to 4.6.1
Actions #6

Updated by Mr. Jenkins almost 13 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

Actions #7

Updated by Chris topher almost 13 years ago

  • Target version changed from 4.6.1 to 4.6.2
Actions #8

Updated by Gerrit Code Review almost 13 years ago

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

Actions #9

Updated by Oliver Klee almost 13 years ago

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

Actions #10

Updated by Xavier Perseguers almost 13 years ago

  • Target version deleted (4.6.2)
Actions #11

Updated by Gerrit Code Review over 12 years ago

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

Actions #12

Updated by Gerrit Code Review over 12 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

Actions #13

Updated by Gerrit Code Review over 12 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

Actions #14

Updated by Gerrit Code Review over 12 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

Actions #15

Updated by Mario Rimann over 12 years ago

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

Updated by Gerrit Code Review over 12 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

Actions #17

Updated by Gerrit Code Review over 12 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

Actions #18

Updated by Mario Rimann about 12 years ago

  • Status changed from Under Review to Resolved
Actions #19

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF