Bug #75625 [Opn->Fbk]: Wrong Mime-Type returned by mime_content_type function with some PDF

From: Date: Mon, 04 Dec 2017 17:58:40 +0000
Subject: Bug #75625 [Opn->Fbk]: Wrong Mime-Type returned by mime_content_type function with some PDF
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212916@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75625&edit=1 ID: 75625 Updated by: requinix@php.net Reported by: vanderelst dot david at gmail dot com Summary: Wrong Mime-Type returned by mime_content_type function with some PDF -Status: Open +Status: Feedback Type: Bug Package: Filesystem function related Operating System: Debian 4.9.18-1 PHP Version: 7.0.26 Block user comment: N Private report: N New Comment: According to the official standard for application/pdf, > All PDF files start with the characters "%PDF-" > followed by the PDF version number, e.g., "%PDF-1.7" or > "%PDF-2.0". These characters are in US-ASCII encoding. https://tools.ietf.org/html/rfc8118 If something inserted characters before the %PDF then it is not obeying the standard. What characters and editors? Previous Comments: ------------------------------------------------------------------------ [2017-12-04 17:23:44] vanderelst dot david at gmail dot com Description: ------------ When checking PDF, in some case the mime type returned by this function will be wrong. The thing is that some editors add stuff before the %PDF string in the file. And this is exactly the issue. The %PDF string can be found in the first 1024 bytes andkeep the PDF valid. I tried to remove the specials chars from the file and the function detect the correct mime type. Test script: --------------- - Create a PDF - test the function - it swill return application/pdf - edit the file and add some chars at the beginning before %PDF - retry and it will return text/plain Expected result: ---------------- application/pdf Actual result: -------------- it returns text/plain ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75625&edit=1

« previous php.bugs (#212916) next »