From e8fd2e2a11df1249c6fe434e9d0cfd6607d75ad0 Mon Sep 17 00:00:00 2001 From: Chris Burgess Date: Sat, 20 Jun 2015 20:34:14 +1200 Subject: [PATCH] CRM-16313. Do not reject IDN email addresses. --- packages/HTML/QuickForm/Rule/Email.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/HTML/QuickForm/Rule/Email.php b/packages/HTML/QuickForm/Rule/Email.php index fc3ead19ea71..40316616fe7d 100644 --- a/packages/HTML/QuickForm/Rule/Email.php +++ b/packages/HTML/QuickForm/Rule/Email.php @@ -3,7 +3,7 @@ /** * Email validation rule - * + * * PHP versions 4 and 5 * * LICENSE: This source file is subject to version 3.01 of the PHP license @@ -22,7 +22,7 @@ */ /** - * Abstract base class for QuickForm validation rules + * Abstract base class for QuickForm validation rules */ require_once 'HTML/QuickForm/Rule.php'; @@ -51,6 +51,17 @@ class HTML_QuickForm_Rule_Email extends HTML_QuickForm_Rule */ function validate($email, $checkDomain = false) { + if (function_exists('idn_to_ascii')) { + if ($parts = explode('@', $email)) { + if (sizeof($parts) == 2) { + foreach ($parts as &$part) { + $part = idn_to_ascii($part); + } + $email = implode('@', $parts); + } + } + } + // Fix for bug #10799: add 'D' modifier to regex if (preg_match($this->regex . 'D', $email)) { if ($checkDomain && function_exists('checkdnsrr')) {