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 70fc463 commit ad169aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions system/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Contao Open Source CMS changelog
Version 3.5.1 (2015-XX-XX)
--------------------------

### Fixed
Fix the `Validator::isEmail()` method (see contao/core-bundle#313).

### Fixed
Strip tags before auto-generating aliases (see #7857).

Expand Down
5 changes: 3 additions & 2 deletions system/modules/core/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 system/modules/core/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 ad169aa

Please sign in to comment.