Bug 700566 - Pressing enter or copying URL on an http:// site whose hostname begins with "ftp<digit>" results in incorrect URL being loaded/copied. r=gavin
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Thu, 10 Nov 2011 14:55:07 +0100
changeset 80150 6194fd540e164405a3b61c7fe7dc5f7386b1162a
parent 80149 14903b2f3f453f79a3820b204972d92aa19d8e38
child 80151 f18be484cb5abd0b20abdd846b4448c9b5a52dc5
push id323
push userrcampbell@mozilla.com
push dateTue, 15 Nov 2011 21:58:36 +0000
treeherderfx-team@3ea216303184 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs700566
milestone11.0a1
Bug 700566 - Pressing enter or copying URL on an http:// site whose hostname begins with "ftp<digit>" results in incorrect URL being loaded/copied. r=gavin
browser/base/content/test/browser_urlbarTrimURLs.js
browser/base/content/utilityOverlay.js
--- a/browser/base/content/test/browser_urlbarTrimURLs.js
+++ b/browser/base/content/test/browser_urlbarTrimURLs.js
@@ -27,17 +27,23 @@ function test() {
   testVal("http://mozilla.imaginatory/", "mozilla.imaginatory");
   testVal("http://www.mozilla.org/", "www.mozilla.org");
   testVal("http://sub.mozilla.org/", "sub.mozilla.org");
   testVal("http://sub1.sub2.sub3.mozilla.org/", "sub1.sub2.sub3.mozilla.org");
   testVal("http://mozilla.org/file.ext", "mozilla.org/file.ext");
   testVal("http://mozilla.org/sub/", "mozilla.org/sub/");
 
   testVal("http://ftp.mozilla.org/", "http://ftp.mozilla.org");
+  testVal("http://ftp1.mozilla.org/", "http://ftp1.mozilla.org");
+  testVal("http://ftp42.mozilla.org/", "http://ftp42.mozilla.org");
+  testVal("http://ftpx.mozilla.org/", "ftpx.mozilla.org");
   testVal("ftp://ftp.mozilla.org/", "ftp://ftp.mozilla.org");
+  testVal("ftp://ftp1.mozilla.org/", "ftp://ftp1.mozilla.org");
+  testVal("ftp://ftp42.mozilla.org/", "ftp://ftp42.mozilla.org");
+  testVal("ftp://ftpx.mozilla.org/", "ftp://ftpx.mozilla.org");
 
   testVal("https://user:pass@mozilla.org/", "https://user:pass@mozilla.org");
   testVal("http://user:pass@mozilla.org/", "http://user:pass@mozilla.org");
   testVal("http://sub.mozilla.org:666/", "sub.mozilla.org:666");
 
   testVal("https://[fe80::222:19ff:fe11:8c76]/file.ext");
   testVal("http://[fe80::222:19ff:fe11:8c76]/", "[fe80::222:19ff:fe11:8c76]");
   testVal("https://user:pass@[fe80::222:19ff:fe11:8c76]:666/file.ext");
--- a/browser/base/content/utilityOverlay.js
+++ b/browser/base/content/utilityOverlay.js
@@ -630,13 +630,15 @@ function openPrefsHelp() {
   // since its probably behind the window.
   var instantApply = getBoolPref("browser.preferences.instantApply");
 
   var helpTopic = document.getElementsByTagName("prefwindow")[0].currentPane.helpTopic;
   openHelpLink(helpTopic, !instantApply);
 }
 
 function trimURL(aURL) {
+  // This function must not modify the given URL such that calling
+  // nsIURIFixup::createFixupURI with the result will produce a different URI.
   return aURL /* remove single trailing slash for http/https/ftp URLs */
              .replace(/^((?:http|https|ftp):\/\/[^/]+)\/$/, "$1")
-              /* remove http:// unless the host starts with "ftp." or contains "@" */
-             .replace(/^http:\/\/((?!ftp\.)[^\/@]+(?:\/|$))/, "$1");
+              /* remove http:// unless the host starts with "ftp\d*\." or contains "@" */
+             .replace(/^http:\/\/((?!ftp\d*\.)[^\/@]+(?:\/|$))/, "$1");
 }