[php-src] Issue #11298: finfo returns wrong mime type for (.tar).xz files
| From: | nilllzz | Date: | Mon, 22 May 2023 22:01:14 +0000 |
| Subject: | [php-src] Issue #11298: finfo returns wrong mime type for (.tar).xz files | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244505@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11298
Author: nilllzz
### Description
### Description
Running a mime type detection on .xz archive files returns an incorrect mime type.
This code:
```
$path = "[Path to .xz file]";
$finfo = new \finfo(FILEINFO_MIME_TYPE);
$mimeData = $finfo->file($path);
echo $mimeData;
```
Resulted in this output:
```
"application/octet-stream"
```
But I expected this output instead:
```
"application/x-xz; charset=binary"
```
This is apparently an issue with libmagic version 5.40 and was fixed in 5.41 (ref https://bugs.astron.com/view.php?id=257).
The specific fix to the magic file can be found here: https://github.com/file/file/commit/9b0459afab309a82aa4e46f73a4e50dd641f3d39
I suggest a similar fix to GH-8805 that was done in https://github.com/php/php-src/commit/34fa65a6c2840e03f4850bb10de0579a20849cb3,
since the issue seems very similar.
### PHP Version
PHP 8.2.3
### Operating System
_No response_