From 0e3cf6f51b4fd056ec70dcf11c5dedc309342377 Mon Sep 17 00:00:00 2001 From: Marius Burkard <m.burkard@pixcept.de> Date: Mon, 3 Oct 2016 17:16:04 +0200 Subject: [PATCH] - use idn constants only if defined, fixes #4237 --- interface/lib/classes/functions.inc.php | 12 ++++++++++-- server/lib/classes/functions.inc.php | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php index 03bd11d390..3a9fcb9a10 100644 --- a/interface/lib/classes/functions.inc.php +++ b/interface/lib/classes/functions.inc.php @@ -302,7 +302,11 @@ class functions { if($encode == true) { if(function_exists('idn_to_ascii')) { - $domain = idn_to_ascii($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); + if(defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46') && constant('IDNA_NONTRANSITIONAL_TO_ASCII')) { + $domain = idn_to_ascii($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); + } else { + $domain = idn_to_ascii($domain); + } } elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) { /* use idna class: * @author Matthias Sommerfeld <mso@phlylabs.de> @@ -319,7 +323,11 @@ class functions { } } else { if(function_exists('idn_to_utf8')) { - $domain = idn_to_utf8($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); + if(defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46') && constant('IDNA_NONTRANSITIONAL_TO_ASCII')) { + $domain = idn_to_utf8($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); + } else { + $domain = idn_to_utf8($domain); + } } elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) { /* use idna class: * @author Matthias Sommerfeld <mso@phlylabs.de> diff --git a/server/lib/classes/functions.inc.php b/server/lib/classes/functions.inc.php index 6a46d5e7fc..1f9c6b6efc 100644 --- a/server/lib/classes/functions.inc.php +++ b/server/lib/classes/functions.inc.php @@ -354,7 +354,11 @@ class functions { if($encode == true) { if(function_exists('idn_to_ascii')) { - $domain = idn_to_ascii($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); + if(defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46') && constant('IDNA_NONTRANSITIONAL_TO_ASCII')) { + $domain = idn_to_ascii($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); + } else { + $domain = idn_to_ascii($domain); + } } elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) { /* use idna class: * @author Matthias Sommerfeld <mso@phlylabs.de> @@ -371,7 +375,11 @@ class functions { } } else { if(function_exists('idn_to_utf8')) { - $domain = idn_to_utf8($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); + if(defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46') && constant('IDNA_NONTRANSITIONAL_TO_ASCII')) { + $domain = idn_to_utf8($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); + } else { + $domain = idn_to_utf8($domain); + } } elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) { /* use idna class: * @author Matthias Sommerfeld <mso@phlylabs.de> -- GitLab