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

Error with determining MIME type for file extensions not listed #568

Merged
merged 1 commit into from Jun 5, 2021

Conversation

schmigz
Copy link
Contributor

@schmigz schmigz commented Jun 5, 2021

fm_get_file_mimes() was causing errors for unknown extensions as it was causing an error as array element was not defined and return value was never checked. According to https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types and several other resources, application/octet-stream is the default value for all other cases. An unknown file type should use this type. I put a check in there to use that by default so a valid value is always returned.

It might be useful to replace this function with the built-in PHP function mime_content_type() but that adds some additional dependencies as it does not always work out of the box with PHP.

fm_get_file_mimes() was causing errors for unknown extensions as it was causing an error as array element was not defined and return value was never checked.  According to https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types and several other resources,  application/octet-stream is the default value for all other cases. An unknown file type should use this type.   I put a check in there to use that by default so a valid value is always returned.

It might be useful to replace this function with the  built-in PHP function mime_content_type() but that adds some additional dependencies as it does not always work out of the box with PHP.
@schmigz schmigz changed the title Update tinyfilemanager.php Error with determining MIME type for file extensions not listed Jun 5, 2021
@prasathmani prasathmani merged commit 8158333 into prasathmani:master Jun 5, 2021
ner00 pushed a commit to ner00/tinyfilemanager that referenced this pull request May 7, 2023
fm_get_file_mimes() was causing errors for unknown extensions as it was causing an error as array element was not defined and return value was never checked.  According to https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types and several other resources,  application/octet-stream is the default value for all other cases. An unknown file type should use this type.   I put a check in there to use that by default so a valid value is always returned.

It might be useful to replace this function with the  built-in PHP function mime_content_type() but that adds some additional dependencies as it does not always work out of the box with PHP.
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

Successfully merging this pull request may close these issues.

None yet

2 participants