Bug 1845552 - patch 1 - Don't let the presence of an invalid-hyphen error (which may be ignored during StringPrepForDNS) mask the presence of other (non-ignorable) types of error in the URL. r=necko-reviewers,valentin

This change gives us 46 new passes on the IdnaTestV2 test collection, with just 6 failures remaining
(to be resolved by the next patch).

Differential Revision: https://phabricator.services.mozilla.com/D186866
This commit is contained in:
Jonathan Kew 2023-08-29 09:20:05 +00:00
parent e41abe4026
commit 74bf676eba
4 changed files with 13 additions and 141 deletions

View File

@ -92,6 +92,13 @@ class IDNA final {
return (mErrorCode & hyphenErrors) != 0;
}
bool HasErrorsIgnoringInvalidHyphen() const {
uint32_t hyphenErrors = UIDNA_ERROR_LEADING_HYPHEN |
UIDNA_ERROR_TRAILING_HYPHEN |
UIDNA_ERROR_HYPHEN_3_4;
return (mErrorCode & ~hyphenErrors) != 0;
}
private:
friend class IDNA;
explicit Info(const UIDNAInfo* aUinfo) : mErrorCode(aUinfo->errors) {}

View File

@ -198,7 +198,7 @@ nsresult nsIDNService::IDNA2008StringPrep(const nsAString& input,
}
bool hasError = flag == eStringPrepForDNS
? info.HasErrors() && !info.HasInvalidHyphen()
? info.HasErrorsIgnoringInvalidHyphen()
: info.HasErrors();
if (hasError) {

View File

@ -951,9 +951,12 @@ add_task(function test_jarURI_serialization() {
});
add_task(async function round_trip_invalid_ace_label() {
let uri = Services.io.newURI("http://xn--xn--d--fg4n-5y45d/");
Assert.equal(uri.spec, "http://xn--xn--d--fg4n-5y45d/");
// This is well-formed punycode, but an invalid ACE label due to hyphens in
// positions 3 & 4 and trailing hyphen. (Punycode-decode yields "xn--d淾-")
let uri = Services.io.newURI("http://xn--xn--d--fg4n/");
Assert.equal(uri.spec, "http://xn--xn--d--fg4n/");
// Entirely invalid punycode will throw a MALFORMED error.
Assert.throws(() => {
uri = Services.io.newURI("http://a.b.c.XN--pokxncvks");
}, /NS_ERROR_MALFORMED_URI/);

View File

@ -11,146 +11,8 @@
[ToASCII("Ä.­.C") A4_2 (ignored)]
expected: FAIL
[ToASCII("ᡖ。̟񗛨ஂ-") P1; V5; V6; V3 (ignored)]
expected: FAIL
[ToASCII("ᡖ。̟񗛨ஂ-") P1; V5; V6; V3 (ignored)]
expected: FAIL
[ToASCII("-.ᢆ󡲣-") P1; V5; V6; V3 (ignored)]
expected: FAIL
[ToASCII("⒈䰹‍-。웈") C2; P1; V6; V3 (ignored)]
expected: FAIL
[ToASCII("⒈䰹‍-。웈") C2; P1; V6; V3 (ignored)]
expected: FAIL
[ToASCII("1.䰹‍-。웈") C2; V3 (ignored)]
expected: FAIL
[ToASCII("1.䰹‍-。웈") C2; V3 (ignored)]
expected: FAIL
[ToASCII("1.xn----tgnz80r.xn--kp5b") C2; V3 (ignored)]
expected: FAIL
[ToASCII("-𐋷𖾑。󠆬") V3 (ignored)]
expected: FAIL
[ToASCII("ꡆ。Ↄྵ놮-") P1; V6; V3 (ignored)]
expected: FAIL
[ToASCII("ꡆ。Ↄྵ놮-") P1; V6; V3 (ignored)]
expected: FAIL
[ToASCII("︅。。𦀾᳠") A4_2 (ignored)]
expected: FAIL
[ToASCII("ς-。‌𝟭-") C1; V3 (ignored)]
expected: FAIL
[ToASCII("ς-。1-") C1; V3 (ignored)]
expected: FAIL
[ToASCII("Σ-。1-") C1; V3 (ignored)]
expected: FAIL
[ToASCII("σ-。1-") C1; V3 (ignored)]
expected: FAIL
[ToASCII("xn----zmb.xn--1--i1t") C1; V3 (ignored)]
expected: FAIL
[ToASCII("xn----xmb.xn--1--i1t") C1; V3 (ignored)]
expected: FAIL
[ToASCII("Σ-。‌𝟭-") C1; V3 (ignored)]
expected: FAIL
[ToASCII("σ-。‌𝟭-") C1; V3 (ignored)]
expected: FAIL
[ToASCII("ς‍-.ⴣ𦟙") C2; V3 (ignored)]
expected: FAIL
[ToASCII("σ-.ⴣ𦟙") C2; V3 (ignored)]
expected: FAIL
[ToASCII("xn----zmb048s.xn--rlj2573p") C2; V3 (ignored)]
expected: FAIL
[ToASCII("xn----xmb348s.xn--rlj2573p") C2; V3 (ignored)]
expected: FAIL
[ToASCII("ᡲ-𝟹.ß--") C1; V3 (ignored)]
expected: FAIL
[ToASCII("ᡲ-3.ß--") C1; V3 (ignored)]
expected: FAIL
[ToASCII("ᡲ-3.SS--") C1; V3 (ignored)]
expected: FAIL
[ToASCII("ᡲ-3.ss--") C1; V3 (ignored)]
expected: FAIL
[ToASCII("ᡲ-3.Ss--") C1; V3 (ignored)]
expected: FAIL
[ToASCII("xn---3-p9o.xn--ss---276a") C1; V3 (ignored)]
expected: FAIL
[ToASCII("xn---3-p9o.xn-----fia9303a") C1; V3 (ignored)]
expected: FAIL
[ToASCII("ᡲ-𝟹.SS--") C1; V3 (ignored)]
expected: FAIL
[ToASCII("ᡲ-𝟹.ss--") C1; V3 (ignored)]
expected: FAIL
[ToASCII("ᡲ-𝟹.Ss--") C1; V3 (ignored)]
expected: FAIL
[ToASCII("-.-├򖦣") P1; V6; V3 (ignored)]
expected: FAIL
[ToASCII("-򷝬፞𑜧.ᷫ-。") P1; V5; V6; V3 (ignored)]
expected: FAIL
[ToASCII("-.ⴞ𐋷") C2; V3 (ignored)]
expected: FAIL
[ToASCII("xn----ugn.xn--mlj8559d") C2; V3 (ignored)]
expected: FAIL
[ToASCII("𝟛꣄𝆪。꣪-") V5; V3 (ignored)]
expected: FAIL
[ToASCII("𝟛꣄𝆪。꣪-") V5; V3 (ignored)]
expected: FAIL
[ToASCII("3꣄𝆪。꣪-") V5; V3 (ignored)]
expected: FAIL
[ToASCII("xn--3-sl4eu679e.xn----xn4e") V5; V3 (ignored)]
expected: FAIL
[ToASCII("ྔꡋ--𖬴") V5; V3 (ignored)]
expected: FAIL
[ToASCII("ྔꡋ-.-𖬴") V5; V3 (ignored)]
expected: FAIL
[ToASCII("xn----ukg9938i.xn----4u5m") V5; V3 (ignored)]
expected: FAIL
[ToASCII("-񕉴.۠ᢚ-") P1; V5; V6; V3 (ignored)]
expected: FAIL
[ToASCII("䃚蟥-。-񽒘⒈") P1; V6; V3 (ignored)]
expected: FAIL
[ToASCII("䃚蟥-。-񽒘1.") P1; V6; V3 (ignored)]
expected: FAIL