Skip to content

Fix GH-25051: Restore TrueType font MIME detection - #25063

Merged
LamentXU123 merged 3 commits into
php:PHP-8.6from
LamentXU123:fix-gh25051
Nov 10, 2026
Merged

LamentXU123 merged 3 commits into
php:PHP-8.6from
LamentXU123:fix-gh25051

Conversation

@LamentXU123

@LamentXU123 LamentXU123 commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Backport file/file@ba72caa54b and regenerate the bundled magic database.
We need to record this to the magicdata.patch‎ file as well since this is a difference between our version of libfile and the upstream.

Backport file/file@ba72caa54b, regenerate the bundled magic database, and add a regression test.
@LamentXU123
LamentXU123 marked this pull request as draft October 30, 2026 19:13
@LamentXU123
LamentXU123 changed the base branch from master to PHP-8.6 October 30, 2026 19:13
@LamentXU123
LamentXU123 marked this pull request as ready for review October 30, 2026 19:14
@DanielEScherzer

Copy link
Copy Markdown
Member

I'm not familiar enough with fileinfo to know if we normally do patches like this
CC @nicolas-grekas who wrote the original patch, https://mailman.astron.com/pipermail/file/2026-October/001731.html

@DanielEScherzer
DanielEScherzer requested a review from a team October 30, 2026 19:36
@ndossche

Copy link
Copy Markdown
Member

I've done patches like this in the past without any RM approval.

@DanielEScherzer

Copy link
Copy Markdown
Member

I've done patches like this in the past without any RM approval.

I don't think RM approval is required, I just (wearing my normally developer hat) thought that the 8.6 RMs should be added as reviewers to make sure that they see this before branching 8.6.0 next week

@nicolas-grekas

Copy link
Copy Markdown
Contributor

At least the diff matches the patch I sent to the list. So 👍 for the backport.

FTR, even with this fix, TTF files get font/ttf on 8.6, where 8.5 returns font/sfnt. That change is upstream since 5.47 and is not a bug, but it might be worth a line in UPGRADING.

@dhrupo

dhrupo commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Drafted with an LLM; I ran every test below and reviewed the results myself.

Tested this with the real fonts from my report (OpenSans-Regular.* from wordpress-develop's test data), on a minimal build (--disable-all --enable-fileinfo, Debian bookworm). finfo(FILEINFO_MIME_TYPE)->file():

File PHP 8.5.12 (libmagic 5.46) PHP-8.6 (bbbb258) This PR (bd8f139)
.ttf font/sfnt application/octet-stream font/ttf
.otf application/vnd.ms-opentype application/vnd.ms-opentype application/vnd.ms-opentype
.woff font/woff font/woff font/woff
.woff2 font/woff2 font/woff2 font/woff2

The TTF description also loses the stray "(FontKit)" it gets on PHP-8.6: TrueType Font data, 18 tables (FontKit), 1st "GDEF" becomes TrueType Font data, 18 tables, 1st "GDEF", the same as on 8.5.

gh25051.phpt fails on PHP-8.6 and passes with this PR. All of ext/fileinfo/tests passes (64 passed, 3 skipped).

One difference from 8.5 remains: TTF is now font/ttf instead of font/sfnt, from the upstream rename in file/file@6481672a8e. Code that expects font/sfnt still rejects TTF on 8.6. WordPress is one example: its font upload allow-list maps ttf to font/sfnt (I've opened https://core.trac.wordpress.org/ticket/66419 for that). Would a note in UPGRADING under fileinfo help? I can open a PR for it.

@LamentXU123
LamentXU123 merged commit 915072e into php:PHP-8.6 Nov 10, 2026
17 of 18 checks passed
TimWolla added a commit that referenced this pull request Nov 10, 2026
* PHP-8.6:
  Update `actions/checkout@v5` to `v7`
  Fix GH-25051: Restore TrueType font MIME detection (#25063)
lacatoire pushed a commit to lacatoire/php-src that referenced this pull request Nov 10, 2026
…5073)

Following the file 5.48 update and the fix in phpGH-25063, fileinfo reports
TrueType fonts as font/ttf rather than the font/sfnt used in PHP 8.5
and earlier.

Document this in the PHP 8.6 upgrade notes so applications with MIME
type allow-lists, including WordPress font uploads, can account for
the changed value.

Closes php#25073
mbeccati pushed a commit that referenced this pull request Nov 10, 2026
Following the file 5.48 update and the fix in GH-25063, fileinfo reports
TrueType fonts as font/ttf rather than the font/sfnt used in PHP 8.5
and earlier.

Document this in the PHP 8.6 upgrade notes so applications with MIME
type allow-lists, including WordPress font uploads, can account for
the changed value.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants