Backed out changeset 5bc25dc3e767 (bug 1772920) for causing geckoview failures

This commit is contained in:
Noemi Erli 2022-11-22 03:01:21 +02:00
parent 144b2ecb64
commit 3bfc64d7f6

View File

@ -4,6 +4,7 @@
"use strict";
ChromeUtils.defineModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
ChromeUtils.defineESModuleGetters(this, {
DownloadPaths: "resource://gre/modules/DownloadPaths.sys.mjs",
});
@ -157,26 +158,21 @@ this.downloads = class extends ExtensionAPI {
return Promise.reject({ message: "filename must not be empty" });
}
if (PathUtils.isAbsolute(filename)) {
const path = OS.Path.split(filename);
if (path.absolute) {
return Promise.reject({
message: "filename must not be an absolute path",
});
}
const pathComponents = PathUtils.splitRelative(filename, {
allowEmpty: true,
allowCurrentDir: true,
allowParentDir: true,
});
if (pathComponents.some(component => component == "..")) {
if (path.components.some(component => component == "..")) {
return Promise.reject({
message: "filename must not contain back-references (..)",
});
}
if (
pathComponents.some(component => {
path.components.some(component => {
const sanitized = DownloadPaths.sanitize(component, {
compressWhitespaces: false,
});