From a09a3fa3b0cd04bef9ea560375b1aca746dab98a Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Fri, 2 Jun 2017 12:54:29 +0100 Subject: [PATCH] support unicode domain names - see #47 --- functions.inc.php | 7 +++++++ setup.php | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/functions.inc.php b/functions.inc.php index 73ea74fa..763e2566 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -199,6 +199,13 @@ function language_selector() { * TODO: skip DNS check if the domain exists in PostfixAdmin? */ function check_domain ($domain) { + + $orig = $domain; + + if(function_exists('idn_to_ascii')) { + $domain = idn_to_ascii($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); + } + if (!preg_match ('/^([-0-9A-Z]+\.)+' . '([-0-9A-Z]){2,13}$/i', ($domain))) { return sprintf(Config::lang('pInvalidDomainRegex'), htmlentities($domain)); } diff --git a/setup.php b/setup.php index 7aaba195..31b29410 100644 --- a/setup.php +++ b/setup.php @@ -52,6 +52,7 @@ $f_session_start = function_exists ("session_start"); $f_preg_match = function_exists ("preg_match"); $f_mb_encode_mimeheader = function_exists ("mb_encode_mimeheader"); $f_imap_open = function_exists ("imap_open"); +$f_intl_exists = function_exists('idn_to_ascii'); $file_config = file_exists (realpath ("./config.inc.php")); @@ -221,6 +222,7 @@ if ($f_sqlite_open == 1) print ""; } + // // Database connection // @@ -303,6 +305,13 @@ else } +if($f_intl_exists == 1) { + print "
  • Optional: Unicode domain name support - OK
  • "; +} +else { + // see inc.functions.php -> check_domain() + print "
  • Notice: php intl module - NOT FOUND
    Optional, to support unicode domain names, install php$phpversion-intl
  • "; +}