Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Fix the Validator::isEmail() method (see contao/core-bundle#313).
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Jul 23, 2015
1 parent e0022b3 commit 976bf6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Resources/contao/library/Contao/Idna.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ public static function encodeEmail($strEmail)
return $strEmail; // see #6241
}

list($strLocal, $strHost) = explode('@', $strEmail);
$arrChunks = explode('@', $strEmail);
$strHost = array_pop($arrChunks);

return $strLocal . '@' . static::encode($strHost);
return implode('@', $arrChunks) . '@' . static::encode($strHost);
}


Expand Down
4 changes: 3 additions & 1 deletion src/Resources/contao/library/Contao/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ public static function isDatim($varValue)
*/
public static function isEmail($varValue)
{
return preg_match('/^(\w+[!#\$%&\'\*\+\-\/=\?^_`\.\{\|\}~]*)+(?<!\.)@\w+([_\.-]*\w+)*\.[A-Za-z]{2,13}$/', \Idna::encodeEmail($varValue));
$email = \Idna::encodeEmail($varValue);

return filter_var($email, FILTER_VALIDATE_EMAIL) === $email;
}


Expand Down

0 comments on commit 976bf6e

Please sign in to comment.