Only test IDN nodes against kMaxDNSNodeLen on string-prepped IDNs that we're going to send to DNS, not the Unicode form for display only. Bug 892370, r=honzab

--HG--
rename : netwerk/test/unit/test_bug722299.js => netwerk/test/unit/test_idn_urls.js
This commit is contained in:
Simon Montagu 2013-07-29 22:32:37 -07:00
parent c934802695
commit f63cb9877d
3 changed files with 17 additions and 7 deletions

View File

@ -623,11 +623,16 @@ nsresult nsIDNService::stringPrepAndACE(const nsAString& in, nsACString& out,
else
rv = encodeToACE(strPrep, out);
}
}
if (out.Length() > kMaxDNSNodeLen) {
NS_WARNING("IDN node too large");
return NS_ERROR_FAILURE;
// Check that the encoded output isn't larger than the maximum length of an
// DNS node per RFC 1034.
// This test isn't necessary in the code paths above where the input is
// ASCII (since the output will be the same length as the input) or where
// we convert to UTF-8 (since the output is only used for display in the
// UI and not passed to DNS and can legitimately be longer than the limit).
if (out.Length() > kMaxDNSNodeLen) {
NS_WARNING("IDN node too large");
return NS_ERROR_FAILURE;
}
}
return rv;

View File

@ -270,7 +270,12 @@ const testcases = [
// Katakana and Hangul
["ハングル한글",
"xn--qck1c2d4a2366lkmzb", false, false, false]
"xn--qck1c2d4a2366lkmzb", false, false, false],
// Thai (also tests that node with over 63 UTF-8 octets doesn't fail)
["เครื่องทําน้ําทําน้ําแข็ง",
"xn--22cdjb2fanb9fyepcbbb9dwh4a3igze4fdcd",
false, true, true]
];

View File

@ -77,7 +77,6 @@ tail =
[test_bug667818.js]
[test_bug669001.js]
[test_bug712914_secinfo_validation.js]
[test_bug722299.js]
[test_bug770243.js]
[test_doomentry.js]
[test_cacheflags.js]
@ -118,6 +117,7 @@ tail =
[test_httpcancel.js]
[test_httpsuspend.js]
[test_idnservice.js]
[test_idn_urls.js]
[test_invalidport.js]
[test_localstreams.js]
[test_mismatch_last-modified.js]