Bug 1034077 - Location bar shouldn't strip whitespace when pasting. r=Gijs
authorDão Gottwald <dao@mozilla.com>
Fri, 04 Jul 2014 17:16:55 +0200
changeset 192394 d031c88447acf7aa5ba0158e3423d597fe27bf75
parent 192393 9c23683e70a2899bd1b81bfc4b4eea5e2ef0aff9
child 192395 bafba8a17aa9a57ff22afb6bb90510eb010b8ebd
push id7604
push userdgottwald@mozilla.com
push dateFri, 04 Jul 2014 15:17:31 +0000
treeherderfx-team@d031c88447ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1034077
milestone33.0a1
Bug 1034077 - Location bar shouldn't strip whitespace when pasting. r=Gijs
browser/base/content/browser.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -5179,28 +5179,32 @@ function middleMousePaste(event) {
   });
 
   event.stopPropagation();
 }
 
 function stripUnsafeProtocolOnPaste(pasteData) {
   // Don't allow pasting in full URIs which inherit the security context.
   const URI_INHERITS_SECURITY_CONTEXT = Ci.nsIProtocolHandler.URI_INHERITS_SECURITY_CONTEXT;
+
   let pastedURI;
-  pasteData = pasteData.trim();
-  do {
-    if (pastedURI) {
-      pasteData = pastedURI.path.trim();
-    }
+  try {
+    pastedURI = makeURI(pasteData.trim());
+  } catch (ex) {
+    return pasteData;
+  }
+
+  while (Services.netutil.URIChainHasFlags(pastedURI, URI_INHERITS_SECURITY_CONTEXT)) {
+    pasteData = pastedURI.path.trim();
     try {
       pastedURI = makeURI(pasteData);
     } catch (ex) {
       break;
     }
-  } while (Services.netutil.URIChainHasFlags(pastedURI, URI_INHERITS_SECURITY_CONTEXT));
+  }
 
   return pasteData;
 }
 
 function handleDroppedLink(event, url, name)
 {
   let lastLocationChange = gBrowser.selectedBrowser.lastLocationChange;