|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-10-09 11:34 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 00:00:01 2025 UTC |
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 " }