[php-src] Issue #11111: Unexpected behaviour with mime_content_type of CSV file (message/news)

From: Date: Fri, 21 Apr 2023 13:57:12 +0000
Subject: [php-src] Issue #11111: Unexpected behaviour with mime_content_type of CSV file (message/news)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244243@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11111 Author: RazorMeister ### Description The following code: ```php <?php // Wrong mime: message/news $fileContent = "ArticleNumber;Producer\nIndex123;Producer1\nIndex1321;Producer2"; $fileName = 'data://,' . urlencode($fileContent); echo mime_content_type($fileName) . PHP_EOL; // Correct mime: text/plain $fileContent = "Number;Producer\nIndex123;Producer1\nIndex1321;Producer2"; $fileName = 'data://,' . urlencode($fileContent); echo mime_content_type($fileName) . PHP_EOL; ``` Resulted in this output: ``` message/news text/plain ``` But I expected this output instead: ``` text/plain text/plain ``` I came across an unexpected behaviour with mime_content_type function. If a file begins with the word: Arcticle, the function returns mime as message/news which is obsoleted: https://www.iana.org/assignments/media-types/message/news Is it possible to fix it? I tested a few websites to test .csv file with that content and in most cases, websites returned the correct mime type: text/csv. Wrong type website: https://www.htmlstrip.com/mime-file-type-checker Correct type website: https://newisty.com/mime-type-checker, https://web-tools.online/type-checker/info Content of tested .csv file ``` ArticleNumber;Producer Index123;Producer1 Index1321;Producer2 ``` ### PHP Version 8.2.3 ### Operating System Ubuntu 20.04

« previous php.bugs (#244243) next »