Skip to content

Commit c575d0d

Browse files
Merge pull request #189 from samsonasik/constant-variant-check
only use INTL_IDNA_VARIANT_UTS46 constant only when exists
2 parents b631d82 + 29a12cf commit c575d0d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Pdp/Parser.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ protected function normalize($part)
303303
$punycoded = (strpos($part, 'xn--') !== false);
304304

305305
if ($punycoded === false) {
306-
$part = idn_to_ascii($part, 0, INTL_IDNA_VARIANT_UTS46);
306+
if (defined('INTL_IDNA_VARIANT_UTS46')) {
307+
$part = idn_to_ascii($part, 0, INTL_IDNA_VARIANT_UTS46);
308+
} else {
309+
$part = idn_to_ascii($part);
310+
}
307311
$this->isNormalized = true;
308312
}
309313

src/Pdp/PublicSuffixListManager.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ public function buildArray(array &$publicSuffixListArray, array $ruleParts)
141141
// of https://publicsuffix.org/list/
142142
// "The domain and all rules must be canonicalized in the normal way
143143
// for hostnames - lower-case, Punycode (RFC 3492)."
144-
$part = idn_to_ascii($part, 0, INTL_IDNA_VARIANT_UTS46);
144+
if (defined('INTL_IDNA_VARIANT_UTS46')) {
145+
$part = idn_to_ascii($part, 0, INTL_IDNA_VARIANT_UTS46);
146+
} else {
147+
$part = idn_to_ascii($part);
148+
}
145149

146150
if (strpos($part, '!') === 0) {
147151
$part = substr($part, 1);

0 commit comments

Comments
 (0)