mirror of
https://github.com/suitenumerique/drive.git
synced 2026-08-17 20:15:40 +02:00
🐛(backend) manage ole2 compound document format
Microsoft has a generic format for files like .xls .doc .ppt and the mimetype returned is application/x-ole-storage. We want to add it to generic type list in order to use the extension instead.
This commit is contained in:
+5
-1
@@ -16,6 +16,10 @@ and this project adheres to
|
||||
|
||||
- 🔥(global) remove notion of workspace
|
||||
|
||||
### Fixed
|
||||
|
||||
- 🐛(backend) manage ole2 compound document format
|
||||
|
||||
## [v0.12.0] - 2026-02-06
|
||||
|
||||
### Added
|
||||
@@ -292,4 +296,4 @@ and this project adheres to
|
||||
[v0.2.0]: https://github.com/suitenumerique/drive/releases/v0.2.0
|
||||
[v0.1.1]: https://github.com/suitenumerique/drive/releases/v0.1.1
|
||||
[v0.1.0]: https://github.com/suitenumerique/drive/releases/v0.1.0
|
||||
## [v0.11.1] - 2026-01-13
|
||||
## [v0.11.1] - 2026-01-13
|
||||
|
||||
@@ -202,6 +202,7 @@ def detect_mimetype(file_buffer: bytes, filename: str | None = None) -> str:
|
||||
# Generic/unreliable MIME types that we should try to improve
|
||||
generic_types = {
|
||||
"application/octet-stream",
|
||||
"application/x-ole-storage", # used by .xls, .doc and .ppt
|
||||
"application/zip",
|
||||
"text/plain",
|
||||
}
|
||||
|
||||
@@ -144,3 +144,15 @@ def test_detect_mimetype_powerpoint_ppt():
|
||||
"application/vnd.ms-powerpoint",
|
||||
"application/mspowerpoint",
|
||||
]
|
||||
|
||||
|
||||
def test_detect_mimetype_ole_storage():
|
||||
"""
|
||||
Microsoft files .xls .doc .ppt can use the mimetype application/x-ole-storage
|
||||
for Microsoft OLE2/Compound File Binary Format. In that case we want to rely on the extension
|
||||
"""
|
||||
|
||||
xls_ole_content = b"\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1"
|
||||
mimetype = utils.detect_mimetype(xls_ole_content, filename="document.xls")
|
||||
|
||||
assert mimetype == "application/vnd.ms-excel"
|
||||
|
||||
Reference in New Issue
Block a user