Skip to content

Commit 0e3cf6f

Browse files
author
Marius Burkard
committed
- use idn constants only if defined, fixes #4237
1 parent 7000d9b commit 0e3cf6f

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

interface/lib/classes/functions.inc.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ private function _idn_encode_decode($domain, $encode = true) {
302302

303303
if($encode == true) {
304304
if(function_exists('idn_to_ascii')) {
305-
$domain = idn_to_ascii($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
305+
if(defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46') && constant('IDNA_NONTRANSITIONAL_TO_ASCII')) {
306+
$domain = idn_to_ascii($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
307+
} else {
308+
$domain = idn_to_ascii($domain);
309+
}
306310
} elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) {
307311
/* use idna class:
308312
* @author Matthias Sommerfeld <mso@phlylabs.de>
@@ -319,7 +323,11 @@ private function _idn_encode_decode($domain, $encode = true) {
319323
}
320324
} else {
321325
if(function_exists('idn_to_utf8')) {
322-
$domain = idn_to_utf8($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
326+
if(defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46') && constant('IDNA_NONTRANSITIONAL_TO_ASCII')) {
327+
$domain = idn_to_utf8($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
328+
} else {
329+
$domain = idn_to_utf8($domain);
330+
}
323331
} elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) {
324332
/* use idna class:
325333
* @author Matthias Sommerfeld <mso@phlylabs.de>

server/lib/classes/functions.inc.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,11 @@ private function _idn_encode_decode($domain, $encode = true) {
354354

355355
if($encode == true) {
356356
if(function_exists('idn_to_ascii')) {
357-
$domain = idn_to_ascii($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
357+
if(defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46') && constant('IDNA_NONTRANSITIONAL_TO_ASCII')) {
358+
$domain = idn_to_ascii($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
359+
} else {
360+
$domain = idn_to_ascii($domain);
361+
}
358362
} elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) {
359363
/* use idna class:
360364
* @author Matthias Sommerfeld <mso@phlylabs.de>
@@ -371,7 +375,11 @@ private function _idn_encode_decode($domain, $encode = true) {
371375
}
372376
} else {
373377
if(function_exists('idn_to_utf8')) {
374-
$domain = idn_to_utf8($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
378+
if(defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46') && constant('IDNA_NONTRANSITIONAL_TO_ASCII')) {
379+
$domain = idn_to_utf8($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
380+
} else {
381+
$domain = idn_to_utf8($domain);
382+
}
375383
} elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) {
376384
/* use idna class:
377385
* @author Matthias Sommerfeld <mso@phlylabs.de>

0 commit comments

Comments
 (0)