Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Playwright ExtractZip

From Leeroopedia

Template:Implementation Page

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 file
  • opts.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

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment