From e570f7a2390a96d00e5b1d871ed2b248f886f93f Mon Sep 17 00:00:00 2001 From: Alexander Fedyashov Date: Sat, 18 Nov 2017 21:32:25 +0200 Subject: [PATCH] fix(IDN): use INTL_IDNA_VARIANT_UTS46 for idn_* functions (#20) * fix(IDN): use INTL_IDNA_VARIANT_UTS46 for idn_* functions * fix(IDN): use INTL_IDNA_VARIANT_UTS46 for idn_* functions --- .travis.yml | 2 ++ src/IDN.php | 8 ++++++++ travis/docker/php-7.2-intl/Dockerfile | 7 +++++++ travis/docker/php-7.2/Dockerfile | 6 ++++++ 4 files changed, 23 insertions(+) create mode 100644 travis/docker/php-7.2-intl/Dockerfile create mode 100644 travis/docker/php-7.2/Dockerfile diff --git a/.travis.yml b/.travis.yml index 3d27a61..765ea50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,8 @@ env: - ENGINE=php VERSION=7.0 INTL=1 - ENGINE=php VERSION=7.1 INTL=0 - ENGINE=php VERSION=7.1 INTL=1 + - ENGINE=php VERSION=7.2 INTL=0 + - ENGINE=php VERSION=7.2 INTL=1 - ENGINE=hhvm INTL=0 before_script: diff --git a/src/IDN.php b/src/IDN.php index 979db5c..b919e5b 100644 --- a/src/IDN.php +++ b/src/IDN.php @@ -38,6 +38,10 @@ public function toASCII($domain) return $this->transformer->encode($domain); } + if (defined('INTL_IDNA_VARIANT_UTS46')) { + return idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); + } + return idn_to_ascii($domain); } @@ -54,6 +58,10 @@ public function toUTF8($domain) return $this->transformer->decode($domain); } + if (defined('INTL_IDNA_VARIANT_UTS46')) { + return idn_to_utf8($domain, 0, INTL_IDNA_VARIANT_UTS46); + } + return idn_to_utf8($domain); } } diff --git a/travis/docker/php-7.2-intl/Dockerfile b/travis/docker/php-7.2-intl/Dockerfile new file mode 100644 index 0000000..2e1c924 --- /dev/null +++ b/travis/docker/php-7.2-intl/Dockerfile @@ -0,0 +1,7 @@ +FROM php:7.2-rc + +RUN apt-get update && apt-get install -y git zlib1g-dev libicu-dev g++ +RUN docker-php-ext-install intl +RUN docker-php-ext-install zip + +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer diff --git a/travis/docker/php-7.2/Dockerfile b/travis/docker/php-7.2/Dockerfile new file mode 100644 index 0000000..b236c7b --- /dev/null +++ b/travis/docker/php-7.2/Dockerfile @@ -0,0 +1,6 @@ +FROM php:7.2-rc + +RUN apt-get update && apt-get install -y git zlib1g-dev +RUN docker-php-ext-install zip + +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer \ No newline at end of file