generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
Can't set extension as 'zip'.
$extension = match ($mime_type) {
'application/x-bzip2' => 'bz2',
'application/gzip' => 'gz',
'application/x-rar' => 'rar',
'application/epub+zip' => 'epub',
'application/pdf' => 'pdf',
'application/zip' => 'zip',
'application/x-tar' => 'tar',
'application/x-7z-compressed' => '7z',
'application/x-cbr' => 'rar',
'application/x-cbz' => 'cbz',
'application/x-cbt' => 'tar',
'application/x-cb7' => '7z',
default => null,
};
overrides any previuosly set extension
How to reproduce the bug
call readFromString and pass $extension variable
Package Version
latest
PHP Version
8.4
Which operating systems does with happen with?
No response
Notes
public static function readFromString(string $contents, ?string $password = null, ?string $extension = null): BaseArchive
{
$file_info = new \finfo(FILEINFO_MIME_TYPE);
$mime_type = $file_info->buffer($contents);
$extension = match ($mime_type) {
'application/x-bzip2' => 'bz2',
'application/gzip' => 'gz',
'application/x-rar' => 'rar',
'application/epub+zip' => 'epub',
'application/pdf' => 'pdf',
'application/zip' => 'zip',
'application/x-tar' => 'tar',
'application/x-7z-compressed' => '7z',
'application/x-cbr' => 'rar',
'application/x-cbz' => 'cbz',
'application/x-cbt' => 'tar',
'application/x-cb7' => '7z',
default => null,
};
if ($extension === null) {
throw new \Exception('Archive: Error detecting extension from mime type, please add manually archive extension as third parameter of `readFromString()`.');
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working