[php-src] Issue #9892: finfo reports different mime type for .txt files containing CSV
| From: | mind-bending-forks | Date: | Fri, 04 Nov 2022 17:56:45 +0000 |
| Subject: | [php-src] Issue #9892: finfo reports different mime type for .txt files containing CSV | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242751@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9892
Author: mind-bending-forks
### 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