Closed Surt closed 6 months ago
Hi @Surt, apologies for the delay in responding to this, I appear to have missing the notification.
I don't exactly remember what the reasoning was when I first wrote this (~7 years ago now), though I remember looking into the implementations of a number of libraries. Inferring the mime type from the contents does seems more secure (if a little slower) than taking the client's submission at face value.
I am not opposed to changing this to use that approach in the library (PR welcome). You can also register your own adapter in the config which overrides that method.
I have implemented more explicit handling of client-provided mime types vs. mime type inferred from the file content in the branch for the upcoming major version release
I was having a problem where some mime_types in files where wrong recognized as text/plain Finally I extended
SourceAdapter\UploadedFileAdapter
so it uses:mime_contents_type($this->path())
instead of$this->getClientMimeType($this->source)
Now the files are recognized as the correct mime_typesIs there any advice not to rewrite it? Why would I prefer the ClientMimeType? Am I doing it wrong?