[HttpFoundation] Mimetype invalid guesser, Suggest adding magic file?#6963
[HttpFoundation] Mimetype invalid guesser, Suggest adding magic file?#6963JoshuaEstes wants to merge 2 commits intosymfony:masterfrom
Conversation
|
Having our own magic file does not sound good but as this is something that come up from time to time, that might be a good idea after all. Can you reference all the other tickets here to get easy access to past discussions? |
|
Issue #5258 It looks like there are a few others but it's not clear if that's what the root cause is? I searched for tickets with "mime" and "mimetype" as well as split up "mime type". I haven't looked into it too much, but could there be a way to add another MimeTypeGuesser that uses a magic file file? Then it would just be a simple |
|
Seems like a good idea indeed. Do you want to work on a PR? |
|
Sure, I can get you something after I'm done updating a few other things. Thanks |
|
Sorry it took so long to get this up here, it's very basic. The My thought is that, if users need something specific that they should be able to use this and not rely on the magic file here (might be worth deleting?). I'd be more than happen to add a cookbook entry if need be, however, I would like to do some more testing with this. If there is anything anyone can think of that I'm overlooking, please let me know. |
|
Why don't you simply add the possibility to pass the magic file path into the existing FileinfoMimeTypeGuesser? I think there is no need to create another implementation (FileinfoMagicMimeTypeGuesser). |
|
Could be worth a try, I'll take a look at it later when I'm not as busy. |
…nfoMimeTypeGuesser (closes symfony#6963)
|
Closing in favor of #7809, where I implemented the possibility to configure the magic file from the existing class as suggested by @raziel057 . Adding a magic file in Symfony itself is not a good idea at the magic file format changed recently (according to the PHP documentation). |
This PR was merged into the master branch. Discussion ---------- [WIP][HttpFoundation] File mime types and extensions | Q | A | ------------- | --- | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #5039, #6963, #5258, #7415, #5615 | License | MIT | Doc PR | n/a This pull request addresses most of the issues regarding mime types and extension on File instances. I've also created an issue on the docs to add more documentation about how things work (see symfony/symfony-docs#2542). Commits ------- acc2b6a [HttpFoundation] updated the list of known mime types (sync from Apache) f85cdd2 [HttpFoundation] fixed phpdoc 1aa68da [HttpFoundation] added a way to inject a custom magic file into FileinfoMimeTypeGuesser (closes #6963) 29b5413 [HttpFoundation] added some more phpdocs to clarify usage ee784fb clarified how/when to use client or guessed mime-types and extensions on a File instance (closes #5039)
So, I had an odd issue which has been discussed various times and already has a number of issues for it already. Not much has been really said in the ways of a good work around. Would like to see what the thoughts are on having a default magic file maintained. According to http://www.php.net/manual/en/function.finfo-open.php you are able to pass in your own. Which should clear up some of the "application/zip" for docx files and others.