Implementation:Microsoft Playwright ExtractZip
Appearance
Overview
ExtractZip is a third-party zip extraction utility (from Max Ogden) bundled with Playwright for extracting downloaded browser archives during browser installation.
Description
The module provides an Extractor class that uses yauzl for zip file reading and handles:
- Streaming extraction of zip entries to the filesystem
- Directory creation for nested entries
- Symlink support for Unix-style zip entries
- File permission preservation from zip entry external attributes
- Path traversal protection (rejects entries with
..segments) - Cancelation support for aborting mid-extraction
The module exports a simple async function interface: extract(zipPath, opts).
Usage
Used by Playwright's browser download system to extract browser binaries from downloaded zip archives.
Code Reference
Source Location
packages/playwright-core/bundles/zip/src/third_party/extract-zip.js (199 lines)
Function Signature
module.exports = async function extract(zipPath, opts) {
// opts.dir: string -- extraction target directory
// opts.onEntry?: (entry, zipfile) => void -- per-entry callback
// opts.defaultDirMode?: number -- default directory permissions
// opts.defaultFileMode?: number -- default file permissions
}
Import
import extract from './third_party/extract-zip';
I/O Contract
Inputs
zipPath: string-- path to the zip fileopts.dir: string-- target extraction directory
Outputs
- Extracted files written to the target directory
- File permissions preserved from zip metadata
- Symlinks created for symbolic link entries
Related Pages
- Microsoft_Playwright_FileUtils -- File system utilities
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment