[php-src] Issue #25051: finfo detects TrueType fonts as application/octet-stream since libmagic 5.48
| From: | dhrupo | Date: | Fri, 30 Oct 2026 08:22:20 +0000 |
| Subject: | [php-src] Issue #25051: finfo detects TrueType fonts as application/octet-stream since libmagic 5.48 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-253929@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/25051
Author: dhrupo
### Description
Since the bundled libmagic was upgraded to 5.48 (bbb345b363),
finfo no longer
recognizes TrueType fonts.
The following code:
```php
<?php
$finfo = new finfo(FILEINFO_MIME_TYPE);
var_dump($finfo->file('OpenSans-Regular.ttf'));
```
Resulted in this output on PHP 8.6.0-dev (PHP-8.6 branch, libmagic 5.48):
```
string(24) "application/octet-stream"
```
But I expected this output instead (PHP 8.5.12, libmagic 5.46):
```
string(9) "font/sfnt"
```
This is an upstream regression from the FontKit rule added in file 5.48. It was fixed upstream in https://github.com/file/file/commit/ba72caa54b
("TrueType fonts lose their MIME type since the FontKit change"). Loading the upstream
magic from master with libmagic 5.48 gives font/ttf for the same file. Upstream changed
the TrueType MIME type from font/sfnt to font/ttf earlier, in https://github.com/file/file/commit/6481672a8e.
OTF, WOFF and WOFF2 are detected as before. The font I used is
tests/phpunit/data/fonts/OpenSans-Regular.ttf from wordpress-develop. WordPress font
uploads of TTF files fail on 8.6 because of this.
### PHP Version
```plain
PHP 8.6.0-dev (cli) (built: Oct 24 2026 22:20:09) (NTS)
```
### Operating System
macOS 26 (arm64)