Skip to content

Commit

Permalink
[FB] OSfile | Replace OSFile with pathutils
Browse files Browse the repository at this point in the history
  • Loading branch information
surapunoyousei committed Sep 1, 2023
1 parent 1b53f4a commit ccf1797
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ this.decompressZip = class extends ExtensionAPI {
"open"
);

const { OS } = ChromeUtils.import(
"resource://gre/modules/osfile.jsm"
);

const { FileUtils } = ChromeUtils.import(
"resource://gre/modules/FileUtils.jsm"
);

const { PathUtils } = ChromeUtils.importESModule(
"shared/modules/PathUtils.sys.mjs"
);

return {
decompressZip: {
async decompress(zipPath, targetDirPath) {
Expand All @@ -44,11 +44,11 @@ this.decompressZip = class extends ExtensionAPI {
});
for (let entry of entries) {
let entryPath = String(entry);
if (OS.Path.normalize(entryPath).startsWith("..") ||
OS.Path.normalize(entryPath).startsWith("/")) {
throw "!!! Zip Slip detected !!!";
if (PathUtils.normalize(entryPath).startsWith("..") ||
PathUtils.normalize(entryPath).startsWith("/")) {
throw new console.error( "!!! Zip Slip detected !!!");
}
let path = OS.Path.join(
let path = PathUtils.join(
targetDirPath,
AppConstants.platform === "win" ?
entryPath.replaceAll("/", "\\") :
Expand All @@ -61,7 +61,6 @@ this.decompressZip = class extends ExtensionAPI {
}

zipreader.close();
return;
},
},
};
Expand Down

0 comments on commit ccf1797

Please sign in to comment.