Backed out 1 changesets (bug 1422643) for failing browser/base/content/test/urlbar/browser_removeUnsafeProtocolsFromURLBarPaste.js r=backout on a CLOSED TREE
authorAndreea Pavel <apavel@mozilla.com>
Fri, 05 Jan 2018 02:13:10 +0200
changeset 397899 ea1837bc4e1fb9eae72fae99cfb205c5b662d432
parent 397898 6ad5ec88a8982d83b8097fd76a2383aae94711c6
child 397900 e4bba88811c07450019d179338af382066be3ce2
push id57560
push userapavel@mozilla.com
push dateFri, 05 Jan 2018 00:14:19 +0000
treeherderautoland@e4bba88811c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1422643
milestone59.0a1
backs out6ad5ec88a8982d83b8097fd76a2383aae94711c6
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
Backed out 1 changesets (bug 1422643) for failing browser/base/content/test/urlbar/browser_removeUnsafeProtocolsFromURLBarPaste.js r=backout on a CLOSED TREE Backed out changeset 6ad5ec88a898 (bug 1422643)
browser/base/content/browser.js
browser/base/content/test/urlbar/browser_removeUnsafeProtocolsFromURLBarPaste.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6047,28 +6047,24 @@ function middleMousePaste(event) {
   });
 
   event.stopPropagation();
 }
 
 function stripUnsafeProtocolOnPaste(pasteData) {
   // Don't allow pasting javascript URIs since we don't support
   // LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL for those.
-  while (true) {
-    let scheme = "";
-    try {
-      scheme = Services.io.extractScheme(pasteData);
-    } catch (ex) { }
-    if (scheme != "javascript") {
-      break;
-    }
-
-    pasteData = pasteData.substring(pasteData.indexOf(":") + 1);
-  }
-  return pasteData;
+  let changed = false;
+  let pasteDataNoJS = pasteData.replace(/\r?\n/g, "")
+                               .replace(/^(?:\W*javascript:)+/i,
+                                        () => {
+                                                changed = true;
+                                                return "";
+                                              });
+  return changed ? pasteDataNoJS : pasteData;
 }
 
 // handleDroppedLink has the following 2 overloads:
 //   handleDroppedLink(event, url, name, triggeringPrincipal)
 //   handleDroppedLink(event, links, triggeringPrincipal)
 function handleDroppedLink(event, urlOrLinks, nameOrTriggeringPrincipal, triggeringPrincipal) {
   let links;
   if (Array.isArray(urlOrLinks)) {
--- a/browser/base/content/test/urlbar/browser_removeUnsafeProtocolsFromURLBarPaste.js
+++ b/browser/base/content/test/urlbar/browser_removeUnsafeProtocolsFromURLBarPaste.js
@@ -3,20 +3,17 @@ function test() {
   testNext();
 }
 
 var pairs = [
   ["javascript:", ""],
   ["javascript:1+1", "1+1"],
   ["javascript:document.domain", "document.domain"],
   [" \u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009javascript:document.domain", "document.domain"],
-  ["\u0000\u000a\u000b\u000c\u000d\u000e\u000f\u0010\u0011\u0012\u0013\u0014javascript:document.domain", "document.domain"],
   ["java\nscript:foo", "foo"],
-  ["java\rscript:foo", "foo"],
-  ["java\tscript:foo", "foo"],
   ["http://\nexample.com", "http://example.com"],
   ["http://\nexample.com\n", "http://example.com"],
   ["data:text/html,<body>hi</body>", "data:text/html,<body>hi</body>"],
   // Nested things get confusing because some things don't parse as URIs:
   ["javascript:javascript:alert('hi!')", "alert('hi!')"],
   ["data:data:text/html,<body>hi</body>", "data:data:text/html,<body>hi</body>"],
   ["javascript:data:javascript:alert('hi!')", "data:javascript:alert('hi!')"],
   ["javascript:data:text/html,javascript:alert('hi!')", "data:text/html,javascript:alert('hi!')"],