The actuall email validator uses a regex to validate email addresses.
The TYPO3 core offers a method in t3lib_div to validate email addresses.
This patch replace the regex with t3lib_div::validEmail()
Change-Id: I8157a61b8f056d0a60510ec3a7ba9dcb182cb0e5
Releases: 6.0, 4.7
Resolves: #6970
FLOW3 issue: #39714
Reviewed-on: http://review.typo3.org/13550
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
Reviewed-by: Ingo Pfennigstorf
Tested-by: Ingo Pfennigstorf
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
* Checks if the given value is a valid email address.
* If at least one error occurred, the result is FALSE.
*
* Checks if the given value is a valid email address.
* If at least one error occurred, the result is FALSE.
*
- * The regexp is a modified version of the last one shown on
- * http://www.regular-expressions.info/email.html
- *
* @param mixed $value The value that should be validated
* @return boolean TRUE if the value is valid, FALSE if an error occured
*/
public function isValid($value) {
$this->errors = array();
* @param mixed $value The value that should be validated
* @return boolean TRUE if the value is valid, FALSE if an error occured
*/
public function isValid($value) {
$this->errors = array();
- if (is_string($value) && preg_match('
- /^
- [a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*
- @
- (?:
- (?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[a-z]{2}|aero|asia|biz|cat|com|edu|coop|gov|info|int|invalid|jobs|localdomain|mil|mobi|museum|name|net|org|pro|tel|travel)|
- localhost|
- (?:(?:\d{1,2}|1\d{1,2}|2[0-4][0-9]|25[0-5])\.){3}(?:(?:\d{1,2}|1\d{1,2}|2[0-4][0-9]|25[0-5]))
- )
- $/Dix', $value)) {
+
+ if (is_string($value) && t3lib_div::validEmail($value)) {
$this->addError('The given subject was not a valid email address.', 1221559976);
return FALSE;
}
$this->addError('The given subject was not a valid email address.', 1221559976);
return FALSE;
}
public function validAddresses() {
return array(
array('andreas.foerthner@netlogix.de'),
public function validAddresses() {
return array(
array('andreas.foerthner@netlogix.de'),
- array('user@localhost'),
array('user@localhost.localdomain'),
array('info@guggenheim.museum'),
array('just@test.invalid'),
array('user@localhost.localdomain'),
array('info@guggenheim.museum'),
array('just@test.invalid'),
- array('just+spam@test.de'),
- array('local@192.168.0.2')
+ array('just+spam@test.de')
public function validAddresses() {
return array(
array('andreas.foerthner@netlogix.de'),
public function validAddresses() {
return array(
array('andreas.foerthner@netlogix.de'),
- array('user@localhost'),
array('user@localhost.localdomain'),
array('info@guggenheim.museum'),
array('just@test.invalid'),
array('user@localhost.localdomain'),
array('info@guggenheim.museum'),
array('just@test.invalid'),
- array('just+spam@test.de'),
- array('just+spam@192.168.249.100'),
- array('local@192.168.0.2')
+ array('just+spam@test.de')