Bug #80887 [Com]: MIME type is changed for archives created by ZipArchive

From: Date: Fri, 16 Apr 2021 18:06:41 +0000
Subject: Bug #80887 [Com]: MIME type is changed for archives created by ZipArchive
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233471@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80887&edit=1 ID: 80887 Comment by: maxsem dot wiki at gmail dot com Reported by: kolesnikov dot p at hotmail dot com Summary: MIME type is changed for archives created by ZipArchive Status: Open Type: Bug Package: Zip Related Operating System: Linux PHP Version: 8.0.3 Block user comment: N Private report: N New Comment: This appears to be a problem with zip file versions. File created with command-line zip 3.0: $ file test.zip test.zip: Zip archive data, at least v2.0 to extract File created with the above code on 3 weeks old PHP 8.1-dev: $ file test1.zip test1.zip: Zip archive data, at least v1.0 to extract Then I checked what finfo thinks about these files: $ php -a Interactive shell php > $info = new finfo(FILEINFO_MIME_TYPE); echo $info->file('test1.zip') . PHP_EOL; application/octet-stream php > $info = new finfo(FILEINFO_MIME_TYPE); echo $info->file('test.zip') . PHP_EOL; application/zip But then I rebuilt my PHP with newer changes that include https://github.com/php/php-src/commit/3b9173dc8f3bda99e87003f6b6b2a16fa25c1b72#diff-4371103b525bd66a8f9765a700a60276ee5a5e26115b9aeb190e6657c457862e with friends and it started producing application/zip in both cases. Does that resolve this bug? Does it make sense to backport? Previous Comments: ------------------------------------------------------------------------ [2021-03-23 14:15:02] cmb@php.net I wonder if there is really a difference between the created ZIP archives (what might be caused by different libzip versions), or whether there is an issue with finfo. ------------------------------------------------------------------------ [2021-03-19 00:49:09] kolesnikov dot p at hotmail dot com Last line echo $info->file('test.zip') . PHP_EOL; ------------------------------------------------------------------------ [2021-03-19 00:45:49] kolesnikov dot p at hotmail dot com Description: ------------ In PHP 7 zip archive created with ZipArchive has MIME type 'application/zip'. In PHP 8 MIME type is 'application/octet-stream' Test script: --------------- <?php unlink('test.zip'); $zip = new ZipArchive(); $zip->open('test.zip', ZipArchive::CREATE); $zip->addFromString('test.txt', 'file content goes here'); $zip->close(); $info = new finfo(FILEINFO_MIME_TYPE); echo $info->file('test1.zip') . PHP_EOL; Expected result: ---------------- application/zip Actual result: -------------- PHP7: application/zip PHP8: application/octet-stream ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80887&edit=1

« previous php.bugs (#233471) next »