Skip to content

Commit

Permalink
Merge pull request civicrm#4 from fuzionnz/4.4.15rc1-CRM-16313
Browse files Browse the repository at this point in the history
CRM-16313. Do not reject IDN email addresses.
  • Loading branch information
xurizaemon committed Jun 20, 2015
2 parents 3c8380f + e8fd2e2 commit 4c307a6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/HTML/QuickForm/Rule/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,7 +22,7 @@
*/

/**
* Abstract base class for QuickForm validation rules
* Abstract base class for QuickForm validation rules
*/
require_once 'HTML/QuickForm/Rule.php';

Expand Down Expand Up @@ -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')) {
Expand Down

0 comments on commit 4c307a6

Please sign in to comment.