From 290894f3c9ef9c8658549baeb805ac154672775c Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Mon, 16 Oct 2017 10:19:52 +0100 Subject: [PATCH] Bug 1408782 - Force punycode display for IDNs with a sequence. r=valentin --- netwerk/dns/nsIDNService.cpp | 9 +++++++++ netwerk/test/unit/test_idn_urls.js | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/netwerk/dns/nsIDNService.cpp b/netwerk/dns/nsIDNService.cpp index aad6d59f744a..81f36b2a9e96 100644 --- a/netwerk/dns/nsIDNService.cpp +++ b/netwerk/dns/nsIDNService.cpp @@ -750,6 +750,7 @@ bool nsIDNService::isLabelSafe(const nsAString &label) Script lastScript = Script::INVALID; uint32_t previousChar = 0; + uint32_t baseChar = 0; // last non-diacritic seen (base char for marks) uint32_t savedNumberingSystem = 0; // Simplified/Traditional Chinese check temporarily disabled -- bug 857481 #if 0 @@ -830,6 +831,14 @@ bool nsIDNService::isLabelSafe(const nsAString &label) } } } + // Check for diacritics on dotless-i, which would be indistinguishable + // from normal accented letter i. + if (baseChar == 0x0131 && + ((ch >= 0x0300 && ch <= 0x0314) || ch == 0x031a)) { + return false; + } + } else { + baseChar = ch; } if (script != Script::COMMON && script != Script::INHERITED) { diff --git a/netwerk/test/unit/test_idn_urls.js b/netwerk/test/unit/test_idn_urls.js index 43f3a2f110a4..57d1191ad3b9 100644 --- a/netwerk/test/unit/test_idn_urls.js +++ b/netwerk/test/unit/test_idn_urls.js @@ -303,6 +303,13 @@ const testcases = [ // Hebrew diacritic also not allowed in Latin text (bug 1404349) ["goo\u05b4gle", "xn--google-rvh", false, false, false], + + // Accents above dotless-i are not allowed + ["na\u0131\u0308ve", "xn--nave-mza04z", false, false, false], + ["d\u0131\u0302ner", "xn--dner-lza40z", false, false, false], + // but the corresponding accented-i (based on dotted i) is OK + ["na\u00efve.com", "xn--nave-6pa.com", false, true, true], + ["d\u00eener.com", "xn--dner-0pa.com", false, true, true], ]; const profiles = ["ASCII", "high", "moderate"];