From ce0ede24ded2e05489f5bab50cc53426599532e4 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Tue, 3 Oct 2017 18:44:24 +0800 Subject: [PATCH] Use IDNA2008 for converting domains to ASCII --- library/HTMLPurifier/AttrDef/URI/Host.php | 2 +- tests/HTMLPurifier/AttrDef/URI/HostTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/library/HTMLPurifier/AttrDef/URI/Host.php b/library/HTMLPurifier/AttrDef/URI/Host.php index 3b4d1867..e54a3344 100644 --- a/library/HTMLPurifier/AttrDef/URI/Host.php +++ b/library/HTMLPurifier/AttrDef/URI/Host.php @@ -97,7 +97,7 @@ class HTMLPurifier_AttrDef_URI_Host extends HTMLPurifier_AttrDef // PHP 5.3 and later support this functionality natively if (function_exists('idn_to_ascii')) { - $string = idn_to_ascii($string); + $string = idn_to_ascii($string, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); // If we have Net_IDNA2 support, we can support IRIs by // punycoding them. (This is the most portable thing to do, diff --git a/tests/HTMLPurifier/AttrDef/URI/HostTest.php b/tests/HTMLPurifier/AttrDef/URI/HostTest.php index aa8ffc68..561fcef3 100644 --- a/tests/HTMLPurifier/AttrDef/URI/HostTest.php +++ b/tests/HTMLPurifier/AttrDef/URI/HostTest.php @@ -49,6 +49,7 @@ class HTMLPurifier_AttrDef_URI_HostTest extends HTMLPurifier_AttrDefHarness } $this->config->set('Core.EnableIDNA', true); $this->assertDef("\xE4\xB8\xAD\xE6\x96\x87.com.cn", "xn--fiq228c.com.cn"); + $this->assertDef("faß.de", "xn--fa-hia.de"); $this->assertDef("\xe2\x80\x85.com", false); // rejected } -- 2.11.4.GIT