php / php/doc-en

Used libmagic versions are not documented

Open
#2,033 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Extension: enchant
Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

Description

Prior to PHP 8, the finfo extension would always report that files with the .txt extension had a mime type of text/plain (I think). Certainly, files that had contents that looked like CSV would return a mime type of text/plain.

From PHP 8.0.1 to 8.0.25, the finfo extension returns a mime type of application/csv if the file contains something that looks like CSV.

From PHP 8.1.0+, the finfo extension returns a mime type of text/csv if the file contains something that looks like CSV.

This is demonstrated at https://3v4l.org/tmGQe

I'm not sure if this change of behaviour is deliberate or unintentional.

  • If deliberate, then it is a breaking change that ought to be documented, but I cannot find any mention of it in any of the release notes or the php documentation for finfo. (So, in that case, I have misfiled this report. It ought to be a documentation bug.)
  • If unintentional, then I note that there are potential security implications if a file that advertises itself via its extension as a plain text file is treated as something different because finfo has looked inside it and decided it is something else. Therefore, someone should review whether the previous behaviour ought to be reverted.
PHP Version

PHP 7.x - 8.x

Operating System

Ubuntu 20.04 - 22.04

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the finfo documentation and PHP release notes covering PHP 8.0.1 through 8.1.0, then compare the CSV MIME-type behavior in the linked 3v4l reproduction. Determine whether the change was deliberate and document it, or establish that the behavior belongs in a separate bug investigation.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.