finfo detects TrueType fonts as application/octet-stream since libmagic 5.48
Description
Since the bundled libmagic was upgraded to 5.48 (bbb345b363), finfo no longer recognizes TrueType fonts.
The following code:
<?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
PHP 8.6.0-dev (cli) (built: Oct 24 2026 22:20:09) (NTS)
Operating System
macOS 26 (arm64)
@LamentXU123 is this something we can fix before the next 8.6 RC to avoid a regression? And/or should we consider reverting the upgrade?
@DanielEScherzer Hmm, seems like all we need to do is just to backport https://github.com/file/file/commit/ba72caa54b ?
4. @DanielEScherzer Hmm, seems like all we need to do is just to backport file/file@ba72caa54b ?
No idea if there are also other parts that need to be updated, figured you would know and wanted to draw your attention to this
Okay I will check through the upstream repo to see if there are other regressions. I plan to do it before GA cuz I am really busy recently. Let's first fix this #25063
7. Okay I will check through the upstream repo to see if there are other regressions. I plan to do it before GA cuz I am really busy recently. Let's first fix this #25063
Note that this should be done before 8.6.0 is branched, which happens at the last RC, i.e. is expected on Tuesday, November 3rd. After that the 8.6 branch is for 8.6.1 and you would need one of the 8.6 release managers to cherry pick the fix to the release branch
Thanks!