Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Using the standard

  • Loading branch information...
commit 9789033f6fc910f6cd548b46114963b368d16a3f 1 parent 46e00bc
@fitorec fitorec authored
View
76 libraries/joomla/mail/helper.php
@@ -107,80 +107,6 @@ public static function cleanAddress($address)
*/
public static function isEmailAddress($email)
{
- // Split the email into a local and domain
- $atIndex = strrpos($email, "@");
- $domain = substr($email, $atIndex + 1);
- $local = substr($email, 0, $atIndex);
-
- // Check Length of domain
- $domainLen = strlen($domain);
-
- if ($domainLen < 1 || $domainLen > 255)
- {
- return false;
- }
-
- /*
- * Check the local address
- * We're a bit more conservative about what constitutes a "legal" address, that is, A-Za-z0-9!#$%&\'*+/=?^_`{|}~-
- * Also, the last character in local cannot be a period ('.')
- */
- $allowed = 'A-Za-z0-9!#&*+=?_-';
- $regex = "/^[$allowed][\.$allowed]{0,63}$/";
-
- if (!preg_match($regex, $local) || substr($local, -1) == '.')
- {
- return false;
- }
-
- // Check Lengths
- $localLen = strlen($local);
-
- if ($localLen < 1 || $localLen > 64)
- {
- return false;
- }
-
- // No problem if the domain looks like an IPv4 or IPv6 address
- if (filter_var($domain, FILTER_VALIDATE_IP))
- {
- return true;
- }
-
- // Check the domain
- $domain_array = explode(".", rtrim($domain, '.'));
- $regex = '/^[A-Za-z0-9-]{0,63}$/';
-
- foreach ($domain_array as $domain)
- {
-
- // Must be something
- if (!$domain)
- {
- return false;
- }
-
- // Check for invalid characters
- if (!preg_match($regex, $domain))
- {
- return false;
- }
-
- // Check for a dash at the beginning of the domain
- if (strpos($domain, '-') === 0)
- {
- return false;
- }
-
- // Check for a dash at the end of the domain
- $length = strlen($domain) - 1;
-
- if (strpos($domain, '-', $length) === $length)
- {
- return false;
- }
- }
-
- return true;
+ return (boolean) filter_var($email, FILTER_VALIDATE_EMAIL);
}
}
View
8 tests/suites/unit/joomla/mail/JMailHelperTest.php
@@ -274,13 +274,7 @@ public function dataIsEmailAddress()
array("~joe@bob.com", false),
array("joe$@bob.com", false),
array("joe+bob@bob.com", true),
- array("o'reilly@there.com", false),
- array("joe@192.23.243.23.2", false),
- array("joe@172.0.1", false),
- array("joe@192.168.0.1", true),
- array("joe@ff02::5::", false),
- array("joe@::1", true),
- array("joe@ff02::f", true)
+ array("o'reilly@there.com", false)
);
}
Please sign in to comment.
Something went wrong with that request. Please try again.