Bug 824887 - Use the current page's original URI rather than creating a new one for copying from the location bar, stop encoding parentheses explicitly. r=dolske
authorDão Gottwald <dao@mozilla.com>
Mon, 29 Feb 2016 12:51:07 +0100
changeset 322341 8033efa33b55d559f6d8735f4d404435b3fbf57e
parent 322340 81ab1a659071fb4b99852b1c611b341557f21ca4
child 322342 083380e8d36f1ad68ddd565eeee3231ac9196282
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs824887
milestone47.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
Bug 824887 - Use the current page's original URI rather than creating a new one for copying from the location bar, stop encoding parentheses explicitly. r=dolske
browser/base/content/test/general/browser_urlbarCopying.js
browser/base/content/urlbarBindings.xml
--- a/browser/base/content/test/general/browser_urlbarCopying.js
+++ b/browser/base/content/test/general/browser_urlbarCopying.js
@@ -72,26 +72,26 @@ var tests = [
   {
     loadURL: "http://user:pass@mochi.test:8888/browser/browser/base/content/test/general/authenticate.sjs?user=user&pass=pass",
     expectedURL: "mochi.test:8888/browser/browser/base/content/test/general/authenticate.sjs?user=user&pass=pass",
     copyExpected: "http://mochi.test:8888/browser/browser/base/content/test/general/authenticate.sjs?user=user&pass=pass"
   },
 
   // Test escaping
   {
-    loadURL: "http://example.com/()%C3%A9",
-    expectedURL: "example.com/()\xe9",
-    copyExpected: "http://example.com/%28%29%C3%A9"
+    loadURL: "http://example.com/()%28%29%C3%A9",
+    expectedURL: "example.com/()()\xe9",
+    copyExpected: "http://example.com/()%28%29%C3%A9"
   },
   {
-    copyVal: "<example.com/(>)\xe9",
+    copyVal: "<example.com/(>)()\xe9",
     copyExpected: "http://example.com/("
   },
   {
-    copyVal: "e<xample.com/(>)\xe9",
+    copyVal: "e<xample.com/(>)()\xe9",
     copyExpected: "xample.com/("
   },
 
   {
     loadURL: "http://example.com/%C3%A9%C3%A9",
     expectedURL: "example.com/\xe9\xe9",
     copyExpected: "http://example.com/%C3%A9%C3%A9"
   },
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -596,34 +596,38 @@ file, You can obtain one at http://mozil
             let remainder = inputVal.replace(selectedVal, "");
             if (remainder != "" && remainder[0] != "/")
               return selectedVal;
           }
 
           let uriFixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup);
 
           let uri;
-          try {
-            uri = uriFixup.createFixupURI(inputVal, Ci.nsIURIFixup.FIXUP_FLAG_NONE);
-          } catch (e) {}
-          if (!uri)
-            return selectedVal;
+          if (this.getAttribute("pageproxystate") == "valid") {
+            uri = gBrowser.currentURI;
+          } else {
+            // We're dealing with an autocompleted value, create a new URI from that.
+            try {
+              uri = uriFixup.createFixupURI(inputVal, Ci.nsIURIFixup.FIXUP_FLAG_NONE);
+            } catch (e) {}
+            if (!uri)
+              return selectedVal;
+          }
 
           // Only copy exposable URIs
           try {
             uri = uriFixup.createExposableURI(uri);
           } catch (ex) {}
 
           // If the entire URL is selected, just use the actual loaded URI.
           if (inputVal == selectedVal) {
             // ... but only if  isn't a javascript: or data: URI, since those
             // are hard to read when encoded
             if (!uri.schemeIs("javascript") && !uri.schemeIs("data")) {
-              // Parentheses are known to confuse third-party applications (bug 458565).
-              selectedVal = uri.spec.replace(/[()]/g, c => escape(c));
+              selectedVal = uri.spec;
             }
 
             return selectedVal;
           }
 
           // Just the beginning of the URL is selected, check for a trimmed
           // value
           let spec = uri.spec;