Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const debug = require('debug')('extract-zip')
// eslint-disable-next-line node/no-unsupported-features/node-builtins
const { createWriteStream, promises: fs } = require('fs')
const { createWriteStream, promises: fs, realpath } = require('fs')
const getStream = require('get-stream')
const path = require('path')
const { promisify } = require('util')
Expand All @@ -9,6 +9,7 @@ const yauzl = require('yauzl')

const openZip = promisify(yauzl.open)
const pipeline = promisify(stream.pipeline)
const realpathPromised = promisify(realpath)

class Extractor {
constructor (zipPath, opts) {
Expand Down Expand Up @@ -55,7 +56,7 @@ class Extractor {
try {
await fs.mkdir(destDir, { recursive: true })

const canonicalDestDir = await fs.realpath(destDir)
const canonicalDestDir = await realpathPromised(destDir)
const relativeDestDir = path.relative(this.opts.dir, canonicalDestDir)

if (relativeDestDir.split(path.sep).includes('..')) {
Expand Down