Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mimetypes accepted #27

Open
HAL0594 opened this issue Jun 25, 2021 · 1 comment
Open

mimetypes accepted #27

HAL0594 opened this issue Jun 25, 2021 · 1 comment

Comments

@HAL0594
Copy link

HAL0594 commented Jun 25, 2021

It is not specified in the documentation but I would like to know what type of mimetypes the package can read, I had problems with people who upload files with mimetype plain/text or html as msg and I would like to validate the accepted mimetypes.

@hfig
Copy link
Owner

hfig commented Jun 27, 2021

I wouldn't rely on a file extension-to-mime type map to determine if the file is valid. If you see a .msg file in the wild, it's usually given application/vnd.ms-outlook. But it could also be a TNEF file, which usually has the file name winmail.dat and type ​application/ms-tnef or application/vnd.ms-tnef. (This library is untested on TNEF files so behaviour will be undefined.)

You can verify you actually have an OLE compound document that the library can attempt to parse by magic bytes 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cfb/05060311-bfce-4b12-874d-71fd4ce63aea

All of which is out of scope for this library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants