From 9a498212446f6c9a186df5652a7625526b590b78 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sat, 13 Sep 2014 12:36:54 +0200 Subject: Fix validation of email addresses with IDNA domains (#1490067) --- program/lib/Roundcube/rcube_utils.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'program') diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php index 00999ba50..28b16ff57 100644 --- a/program/lib/Roundcube/rcube_utils.php +++ b/program/lib/Roundcube/rcube_utils.php @@ -103,13 +103,14 @@ class rcube_utils } foreach ($domain_array as $part) { - if (!preg_match('/^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]))$/', $part)) { + if (!preg_match('/^((xn--)?([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]))$/', $part)) { return false; } } // last domain part - if (preg_match('/[^a-zA-Z]/', array_pop($domain_array))) { + $last_part = array_pop($domain_array); + if (strpos($last_part, 'xn--') !== 0 && preg_match('/[^a-zA-Z]/', $last_part)) { return false; } -- cgit v1.2.3