Skip to content

Commit

Permalink
Merge pull request ckan#8088 from ckan/Zharktas-patch-2
Browse files Browse the repository at this point in the history
Increase read bytes from file to detect xlsx mimetypes correctly
  • Loading branch information
wardi authored Feb 27, 2024
2 parents 1c45951 + 4f17abf commit 3b3ac6a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/8088.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Detect XLSX mimetypes correctly in uploader
3 changes: 2 additions & 1 deletion ckan/lib/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ def verify_type(self):
if not mimetypes and not types:
return

actual = magic.from_buffer(self.upload_file.read(1024), mime=True)
# 2KB required for detecting xlsx mimetype
actual = magic.from_buffer(self.upload_file.read(2048), mime=True)
self.upload_file.seek(0, os.SEEK_SET)
err: ErrorDict = {
self.file_field: [f"Unsupported upload type: {actual}"]
Expand Down

0 comments on commit 3b3ac6a

Please sign in to comment.