Skip to content

Commit

Permalink
Better protection against malicious zips
Browse files Browse the repository at this point in the history
  • Loading branch information
mhr3 committed Apr 20, 2024
1 parent 4a4be03 commit ab67989
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/unzip-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ UnzipStream.prototype._prepareOutStream = function (vars, entry) {

var isDirectory = vars.uncompressedSize === 0 && /[\/\\]$/.test(entry.path);
// protect against malicious zip files which want to extract to parent dirs
entry.path = entry.path.replace(/^([/\\]*[.]+[/\\]+)*[/\\]*/, "");
entry.path = entry.path.replace(/(?<=^|[/\\]+)[.][.]+(?=[/\\]+|$)/g, ".");
entry.type = isDirectory ? 'Directory' : 'File';
entry.isDirectory = isDirectory;

Expand Down

0 comments on commit ab67989

Please # to comment.