Skip to content

finfo detects TrueType fonts as application/octet-stream since libmagic 5.48 #25051

Open

Description

@dhrupo

Description

Since the bundled libmagic was upgraded to 5.48 (bbb345b), 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 file/file@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 file/file@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)

Activity

  1. added this to the PHP 8.6 milestone on Oct 30, 2026
  2. DanielEScherzer commented on Oct 30, 2026

    @DanielEScherzer
    Member

    @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?

  3. LamentXU123 commented on Oct 30, 2026

    @LamentXU123
    Member

    @DanielEScherzer Hmm, seems like all we need to do is just to backport file/file@ba72caa54b ?

  4. DanielEScherzer commented on Oct 30, 2026

    @DanielEScherzer
    Member

    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

  5. self-assigned this
    on Oct 30, 2026
  6. LamentXU123 commented on Oct 30, 2026

    @LamentXU123
    Member

    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. DanielEScherzer commented on Oct 30, 2026

    @DanielEScherzer
    Member

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions