Skip to content

Commit 89b3fe4

Browse files
xemlockezyang
authored andcommitted
Use IDNA constants only if defined (ezyang#171)
Fixes ezyang#168. Solution based on https://git.ispconfig.org/ispconfig/ispconfig3/commit/0e3cf6f51b4fd.
1 parent 3cb77da commit 89b3fe4

File tree

1 file changed

+5
-1
lines changed
  • library/HTMLPurifier/AttrDef/URI

1 file changed

+5
-1
lines changed

library/HTMLPurifier/AttrDef/URI/Host.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ public function validate($string, $config, $context)
9797

9898
// PHP 5.3 and later support this functionality natively
9999
if (function_exists('idn_to_ascii')) {
100-
$string = idn_to_ascii($string, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
100+
if (defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46')) {
101+
$string = idn_to_ascii($string, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
102+
} else {
103+
$string = idn_to_ascii($string);
104+
}
101105

102106
// If we have Net_IDNA2 support, we can support IRIs by
103107
// punycoding them. (This is the most portable thing to do,

0 commit comments

Comments
 (0)