Skip to content

Commit

Permalink
INTL_IDNA_VARIANT_UTS46 requires ICU 4.6+, disable IDN support if not…
Browse files Browse the repository at this point in the history
… present
  • Loading branch information
kelunik committed Sep 10, 2017
1 parent 63b89f8 commit 2de9466
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function isValidDnsName(string $name) {
function normalizeDnsName(string $name): string {
static $pattern = '/^(?<name>[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)(\.(?&name))*$/i';

if (\function_exists('idn_to_ascii')) {
if (false === $result = \idn_to_ascii($name, 0, INTL_IDNA_VARIANT_UTS46)) {
if (\function_exists('idn_to_ascii') && \defined('INTL_IDNA_VARIANT_UTS46')) {
if (false === $result = \idn_to_ascii($name, 0, \INTL_IDNA_VARIANT_UTS46)) {
throw new InvalidDnsNameException("Name '{$name}' could not be processed for IDN.");
}

Expand All @@ -40,7 +40,7 @@ function normalizeDnsName(string $name): string {
if (\preg_match('/[\x80-\xff]/', $name)) {
throw new InvalidDnsNameException(
"Name '{$name}' contains non-ASCII characters and IDN support is not available. " .
"Verify that ext/intl is installed for IDN support."
"Verify that ext/intl is installed for IDN support and that ICU is at least version 4.6."
);
}
}
Expand Down

0 comments on commit 2de9466

Please sign in to comment.