com web/php: Alters email-verification: include/email-validation.inc
| From: | Christoph Michael Becker | Date: | Thu, 17 Aug 2017 05:15:01 +0000 |
| Subject: | com web/php: Alters email-verification: include/email-validation.inc | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-26327@lists.php.net to get a copy of this message | ||
Commit: c716ac3b05262660372bd0af199aec78c140f3ab
Author: Andreas Heigl <andreas@heigl.org> Thu, 17 Aug 2017 07:15:01 +0200
Parents: f7d90b76d140d0fd14b4afe55844d5f7ff4ac273
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=c716ac3b05262660372bd0af199aec78c140f3ab
Log:
Alters email-verification
The current email-verification is completely based on regex that is not
up-to-date any more in regard to newer TLDs. For example the current
version checks whether the TLD is between 2 and 6 chars long which fails
for ".digital" and some other longer TLDs
I've altered it so that the host-check is done by actually checking for
an MX-record so host that currently validate against the regex will fail
in future when no MX is available.
The Address-Part is still matched against a Regex.
Changed paths:
M include/email-validation.inc
Diff:
diff --git a/include/email-validation.inc b/include/email-validation.inc
index 6b67097..05b964b 100644
--- a/include/email-validation.inc
+++ b/include/email-validation.inc
@@ -12,22 +12,30 @@ function clean_AntiSPAM($email)
// Try to check that this email address is valid
function is_emailable_address($email)
{
- // Exclude our mailing list hosting servers
- $hosts_regex = "!(lists\.php\.net|chek[^\.*]\.com)!i";
- $excluded_hosts = preg_match($hosts_regex, $email);
+ // No email, no validation
+ if (empty($email)) {
+ return false;
+ }
+
+ $parts = explode('@', $email);
+ // An email-address with more than one '@' can't be valid
+ if (count($parts) != 2) {
+ return false;
+ }
- // Email addresses need to match this pattern
- $email_regex = ":^([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~ ])+" .
- "@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~ ]+\\.)+" .
- "[a-zA-Z]{2,6}\$:i";
-
- // If address is not under excluded hosts, and fits the regex,
- // then we belive that it is a good email address
- if (!$excluded_hosts && !empty($email)) {
- return preg_match($email_regex, $email);
- } else {
- return FALSE;
+ // addresses from our mailing-list servers
+ $host_part_regex = "!(lists\.php\.net|chek[^\.*]\.com)!i";
+ if (preg_match($host_part_regex, $email)) {
+ return false;
}
+
+ // When no MX-Entry can be found it's for sure not a valid email-address.
+ if (getmxrr($parts[1], $return_values) === false) {
+ return false;
+ }
+
+ $address_part_regex = ":^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~ ])+:i";
+ return (bool) preg_match($address_part_regex, $parts[0]);
}
/**