josantonius / php-mime-type Goto Github PK
View Code? Open in Web Editor NEWPHP library to get MIME types from extensions
Home Page: https://josantonius.dev
License: MIT License
PHP library to get MIME types from extensions
Home Page: https://josantonius.dev
License: MIT License
With this library you are getting the mime type based on the file extension and not the actual mime type of the file, based on the file content (the actual binary data), which is s HUGE security problem. If someone uses this with form submitted files, they are introducing a massive security hole in their code as the extension of the file can be easily changed by anyone so that they can easily upload a file.
You must place a warning in your readme so that this is not used for form upload purposes or for public facing projects.
Have a look at how PHP does this with the function mime_content_type and look for actual code and you will see that it actually opens the file to read the first bytes.
I realize that you specify that this library determines the mime type from an extension, but you need to warn people about the dangers of that in case someone less experienced uses this for production ready projects where security is very important.
Hope this helps and does not get deleted.
Thanks you for this library ;) You did a great job.
Hope i will be able to help in any kind of maner.
Hello,
It's fix on the last commit.
Have a nice day !
".woff2": "application/x-font-woff2",
It's a common missing since woff2 is quite recent.
Hello,
Since there is millions of systems which are PHP 5 only (at least until the end of 2017 - because of native PHP support from Debian 8 - the latest stable released of Debian - which run now, PHP 5.6.29).
I advice you to make your library PHP 5.6 compliant, by using with awesome one :
if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
// PHP7 only stuff
}
Then, there is some rewriting to do :
I'm currently rewriting all your functions to make it works under PHP 5.6. I will be maybe fork it on Github if i got times.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.