|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78655 Substitute character (^Z) in PDF breaks mime type detection
Submitted: 2019-10-09 11:34 UTC Modified: 2019-11-11 09:54 UTC
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:3 (100.0%)
From: dick at tellow dot nl Assigned: cmb (profile)
Status: Not a bug Package: *Directory/Filesystem functions
PHP Version: 7.1.32 OS: macOS 10.15
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
48 - 24 = ?
Subscribe to this entry?

 [2019-10-09 11:34 UTC] dick at tellow dot nl
Substitute character (^Z) in PDF breaks mime type detection.

If the broken.pdf file contains:

4 0 obj^M$
<< /Length 2625 /Filter [ /FlateDecode ] >>^M$

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);
= string(24) "application/octet-stream"

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-09 12:00 UTC] leeuwd at me dot com
Substitute character ( "In Unix operating systems, this character is typically used to suspend the currently executing interactive process"

Could be the culprit.
 [2019-10-13 18:39 UTC]
What does file(1) report?
 [2019-10-21 08:06 UTC] 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-21 14:02 UTC]
-Status: Open +Status: Feedback
 [2019-10-21 14:02 UTC]
@cmb means the file command run from the terminal.

$ file broken.pdf
 [2019-10-21 14:07 UTC] dick at tellow dot nl
file broken.pdf
=> broken.pdf: data
 [2019-11-03 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2019-11-04 09:16 UTC]
-Status: No Feedback +Status: Not a bug -Package: *General Issues +Package: *Directory/Filesystem functions -Assigned To: +Assigned To: cmb
 [2019-11-04 09:16 UTC]
> file broken.pdf
> => broken.pdf: data

So this looks like an upstream issue, and should reported to
 [2019-11-11 09:47 UTC] dick at tellow dot nl
The issue is still present! 

Can't re-open:this website from the 90s does not allow me to login nor request a new password.
 [2019-11-11 09:54 UTC]
> The issue is still present!

Has it already been fixed upstream?
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Mar 26 07:05:48 2023 UTC