[php-src] Issue #13037: PharData incorrectly extracts zip file

From: Date: Wed, 27 Dec 2023 17:53:43 +0000
Subject: [php-src] Issue #13037: PharData incorrectly extracts zip file
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246147@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/13037
Author: Mezinami

### Description

The following code:

```php
<?php
function archive_extract(string $path, string $destination = ".")
{
	$phar = new PharData($path);
	$phar->extractTo($destination);
}

archive_extract("file.zip", "extracted_dir1");
```
Extracts the zip file with invisible characters such as \x14 and other control characters in a few
of HUNDREDS of files.
Files that are corrupted when extracted:

- https://github.com/NamelessMC/Nameless/releases/download/v2.1.2/nameless-deps-dist.zip
- https://wordpress.org/latest.zip

``diff -r -q /path/to/dir1 /path/to/dir2``  output:
```bash
Files test/wordpress/wp-includes/blocks/site-tagline/editor-rtl.min.css and
test2/wordpress/wp-includes/blocks/site-tagline/editor-rtl.min.css differ
Files test/wordpress/wp-includes/blocks/site-tagline/editor.min.css and
test2/wordpress/wp-includes/blocks/site-tagline/editor.min.css differ
Files test/wordpress/wp-includes/blocks/site-title/style-rtl.css and
test2/wordpress/wp-includes/blocks/site-title/style-rtl.css differ
Files test/wordpress/wp-includes/blocks/site-title/style-rtl.min.css and
test2/wordpress/wp-includes/blocks/site-title/style-rtl.min.css differ
Files test/wordpress/wp-includes/blocks/site-title/style.css and
test2/wordpress/wp-includes/blocks/site-title/style.css differ
Files test/wordpress/wp-includes/blocks/site-title/style.min.css and
test2/wordpress/wp-includes/blocks/site-title/style.min.css differ
Files test/wordpress/wp-includes/blocks/spacer/style-rtl.css and
test2/wordpress/wp-includes/blocks/spacer/style-rtl.css differ
Files test/wordpress/wp-includes/blocks/spacer/style-rtl.min.css and
test2/wordpress/wp-includes/blocks/spacer/style-rtl.min.css differ
```
This code:

```php
<?php
function unzip(string $path, string $destination = ".")
{
    $zip = new ZipArchive;
    $zip->open($path);
    $zip->extractTo($destination);
    $zip->close();
}
archive_extract("file.zip", "extracted_dir2");
```
correctly extracts the zip file as expected, in the same way as command line tool
``unzip`` does.

### PHP Version

PHP 8.2.7

### Operating System

Debian 12.4 raspberrypi


Thread (1 message)

  • Mezinami
« previous php.bugs (#246147) next »