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
authorSimon Montagu <smontagu@smontagu.org>
Mon, 29 Jul 2013 22:32:37 -0700
changeset 140572 1e8481e37d06671b471715b98070bf1a10b6d368
parent 140571 515d75612e530483a10b6fc6faace73ebff48eed
child 140573 e70411983e393cc845d44181151dfdd028a2f0bb
push id31799
push usersmontagu@mozilla.com
push dateTue, 30 Jul 2013 20:20:37 +0000
treeherdermozilla-inbound@1e8481e37d06 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershonzab
bugs892370
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
netwerk/dns/nsIDNService.cpp
netwerk/test/unit/test_bug722299.js
netwerk/test/unit/test_idn_urls.js
netwerk/test/unit/xpcshell.ini
--- a/netwerk/dns/nsIDNService.cpp
+++ b/netwerk/dns/nsIDNService.cpp
@@ -618,21 +618,26 @@ nsresult nsIDNService::stringPrepAndACE(
     nsAutoString strPrep;
     rv = stringPrep(in, strPrep, allowUnassigned);
     if (NS_SUCCEEDED(rv)) {
       if (IsASCII(strPrep))
         LossyCopyUTF16toASCII(strPrep, 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;
 }
 
 // RFC 3490
 // 1) Whenever dots are used as label separators, the following characters
 //    MUST be recognized as dots: U+002E (full stop), U+3002 (ideographic full
rename from netwerk/test/unit/test_bug722299.js
rename to netwerk/test/unit/test_idn_urls.js
--- a/netwerk/test/unit/test_bug722299.js
+++ b/netwerk/test/unit/test_idn_urls.js
@@ -265,17 +265,22 @@ const testcases = [
                  "xn--hangul-8m5th09k79ze",          false, true,  true],
 
     // Hangul and katakana
     ["한글ハングル",
                  "xn--qck1c2d4a9266lkmzb",           false, false, false],
 
     // 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]
 ];
 
 
 const profiles = ["ASCII", "high", "moderate"];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
--- a/netwerk/test/unit/xpcshell.ini
+++ b/netwerk/test/unit/xpcshell.ini
@@ -72,17 +72,16 @@ tail =
 [test_bug654926_doom_and_read.js]
 [test_bug654926_test_seek.js]
 [test_bug659569.js]
 [test_bug660066.js]
 [test_bug667907.js]
 [test_bug667818.js]
 [test_bug669001.js]
 [test_bug712914_secinfo_validation.js]
-[test_bug722299.js]
 [test_bug770243.js]
 [test_doomentry.js]
 [test_cacheflags.js]
 [test_cache_jar.js]
 [test_channel_close.js]
 [test_compareURIs.js]
 [test_compressappend.js]
 [test_content_encoding_gzip.js]
@@ -113,16 +112,17 @@ tail =
 [test_head.js]
 [test_header_Accept-Language.js]
 [test_headers.js]
 [test_http_headers.js]
 [test_httpauth.js]
 [test_httpcancel.js]
 [test_httpsuspend.js]
 [test_idnservice.js]
+[test_idn_urls.js]
 [test_invalidport.js]
 [test_localstreams.js]
 [test_mismatch_last-modified.js]
 [test_MIME_params.js]
 [test_mozTXTToHTMLConv.js]
 [test_multipart_byteranges.js]
 [test_multipart_streamconv.js]
 [test_multipart_streamconv_missing_lead_boundary.js]