Bug 1422643 - deal with tabs in the protocol in js paste detection code, r=florian,valentin

MozReview-Commit-ID: Ax5LGkIedkY
This commit is contained in:
Gijs Kruitbosch
2017-12-20 18:57:48 +00:00
parent fb75261c6d
commit 87ee1fc631
2 changed files with 15 additions and 8 deletions

View File

@@ -6052,14 +6052,18 @@ function middleMousePaste(event) {
function stripUnsafeProtocolOnPaste(pasteData) {
// Don't allow pasting javascript URIs since we don't support
// LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL for those.
let changed = false;
let pasteDataNoJS = pasteData.replace(/\r?\n/g, "")
.replace(/^(?:\W*javascript:)+/i,
() => {
changed = true;
return "";
});
return changed ? pasteDataNoJS : pasteData;
while (true) {
let scheme = "";
try {
scheme = Services.io.extractScheme(pasteData);
} catch (ex) { }
if (scheme != "javascript") {
break;
}
pasteData = pasteData.substring(pasteData.indexOf(":") + 1);
}
return pasteData;
}
// handleDroppedLink has the following 2 overloads: