Skip to content

Commit

Permalink
Use IDNA constants only if defined (ezyang#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
xemlock authored and ezyang committed Mar 5, 2018
1 parent 3cb77da commit 89b3fe4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion library/HTMLPurifier/AttrDef/URI/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ public function validate($string, $config, $context)

// PHP 5.3 and later support this functionality natively
if (function_exists('idn_to_ascii')) {
$string = idn_to_ascii($string, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
if (defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46')) {
$string = idn_to_ascii($string, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
} else {
$string = idn_to_ascii($string);
}

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

0 comments on commit 89b3fe4

Please sign in to comment.