Bug #75625 [NEW]: Wrong Mime-Type returned by mime_content_type function with some PDF
| From: | vanderelst dot david at gmail dot com | Date: | Mon, 04 Dec 2017 17:23:47 +0000 |
| Subject: | Bug #75625 [NEW]: Wrong Mime-Type returned by mime_content_type function with some PDF | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-212915@lists.php.net to get a copy of this message | ||
From: vanderelst dot david at gmail dot com
Operating system: Debian 4.9.18-1
PHP version: 7.0.26
Package: Filesystem function related
Bug Type: Bug
Bug description:Wrong Mime-Type returned by mime_content_type function with some PDF
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 bug report at https://bugs.php.net/bug.php?id=75625&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75625&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75625&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75625&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75625&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75625&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75625&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75625&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75625&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75625&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75625&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75625&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75625&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75625&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75625&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75625&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75625&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75625&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75625&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75625&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75625&r=mysqlcfg