Bug #78655 [Opn->Fbk]: Substitute character (^Z) in PDF breaks mime type detection

From: Date: Mon, 21 Oct 2019 14:02:49 +0000
Subject: Bug #78655 [Opn->Fbk]: Substitute character (^Z) in PDF breaks mime type detection
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223355@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78655&edit=1 ID: 78655 Updated by: requinix@php.net Reported by: dick at tellow dot nl Summary: Substitute character (^Z) in PDF breaks mime type detection -Status: Open +Status: Feedback Type: Bug Package: *General Issues Operating System: macOS 10.15 PHP Version: 7.1.32 Block user comment: N Private report: N New Comment: @cmb means the file command run from the terminal. $ file broken.pdf Previous Comments: ------------------------------------------------------------------------ [2019-10-21 08:06:34] dick at tellow dot nl var_dump(file('broken.pdf')) returns array(9) { [0]=> string(13) "%PDF-1.3 " [1]=> string(36) "%����������� " [2]=> string(9) "4 0 obj " [3]=> string(45) "<< /Length 2625 /Filter [ /FlateDecode ] >> " [4]=> string(8) "stream " [5]=> string(9) "x�� " [6]=> string(6) "Ug� " [7]=> string(1) " " [8]=> string(6) "%%EOF " } ------------------------------------------------------------------------ [2019-10-13 18:39:42] cmb@php.net What does file(1) report? ------------------------------------------------------------------------ [2019-10-09 12:00:51] leeuwd at me dot com Substitute character (https://en.wikipedia.org/wiki/Substitute_character): "In Unix operating systems, this character is typically used to suspend the currently executing interactive process" Could be the culprit. ------------------------------------------------------------------------ [2019-10-09 11:34:55] dick at tellow dot nl Description: ------------ Substitute character (^Z) in PDF breaks mime type detection. If the broken.pdf file contains: ``` %PDF-1.3^M$ %�����������^M$ 4 0 obj^M$ << /Length 2625 /Filter [ /FlateDecode ] >>^M$ stream^M$ x��^Z$ Ug�$ $ %%EOF$ ``` getting the MIME type via finfo or mime_content_type returns the incorrect 'application/octet-stream' instead of the expected 'application/pdf'. Problem occurs on localhost macOS and remote server running Linux. Test script: --------------- $finfo = new \finfo(FILEINFO_MIME_TYPE); var_dump($finfo->file('broken.pdf')); = string(24) "application/octet-stream" Expected result: ---------------- application/pdf Actual result: -------------- application/octet-stream ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78655&edit=1

« previous php.bugs (#223355) next »