Fix wrong mimetype for docx files #2416
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR seeks to resolve #1753, allowing files created by the word2007 writer to be detected as word files and not
application/octet-stream
. I ran into this issue while working on file upload using Laravel's build-in file validation.Based on this magic file, I've deduced how the word file mimetype is detected.
The file needs to be a zip, inside the first two filenames need to match a regex, then the 3rd and 4th filenames are inspected to see what path they start with. When either matches
word/
the file is determined to be a word 2007 file.Before this process would find docProps/, which does pass the regex, but not match an office mimetype, causing the file to get the type MSOOXML
application/octet-stream
.I've added a passing test to ensure this does not pop up again.
I am unsure what documentation needs to be updated for a bugfix.
Fixes #1753
Checklist:
composer run-script check --timeout=0
and no errors were reported