fix 500 error when file extension could not be guessed #79

Manually merged
jonas-w merged 1 commits from jonas-w/0x0:master into master 2023-01-15 20:44:08 +01:00
Contributor

When a file without an extension was uploaded, and the mimetypes.guess_extension returned None, because there is no official file extension for that mimetype, a NoneType was subscripted, which yielded a 500 http error.

This ironically happened when i tried to upload my 0x0 uploader python script, which had no python extension and text/x-script.python is no official IANA mime type thats why guess_extension won't return a .py extension but None.

My fix is to first check if the guess is None and if it is none, then ext will be set to an empty string, so that it falls back to '.bin' in the return statement.

When a file without an extension was uploaded, and the mimetypes.guess_extension returned None, because there is no official file extension for that mimetype, a NoneType was subscripted, which yielded a 500 http error. This ironically happened when i tried to upload my 0x0 uploader python script, which had no python extension and `text/x-script.python` is no official IANA mime type thats why guess_extension won't return a .py extension but `None`. My fix is to first check if the guess is None and if it is none, then ext will be set to an empty string, so that it falls back to '.bin' in the return statement.
jonas-w added 1 commit 2023-01-15 20:33:50 +01:00
93f52a14d2
fix 500 error when file extension could not be guessed
when a file without an extension was uploaded
and the mimetypes.guess_extension returned None
because there is no official file extension
for that mimetype a NoneType was subscripted
which yielded a 500 http error
jonas-w force-pushed master from 93f52a14d2 to 3950f6e8eb 2023-01-15 20:37:05 +01:00 Compare
jonas-w manually merged commit 3950f6e8eb into master 2023-01-15 20:44:08 +01:00
Owner

Oh, thanks! Think this one might have be a regression.

Oh, thanks! Think this one might have be a regression.
Owner

Should now be fixed on the 0x0.st instance as well.

Should now be fixed on the 0x0.st instance as well.
Owner

Feel free to also extend the tests for this. I haven’t gotten around to extending the test suite yet… 😅

Feel free to also extend the tests for this. I haven’t gotten around to extending the test suite yet… 😅
Author
Contributor

Wow that was fast!

if i stumble on more bugs while developing my 0x0 cli (struggling with finding a name) i will definitely let you know and probably fix them 😊

Wow that was fast! if i stumble on more bugs while developing my 0x0 cli (struggling with finding a name) i will definitely let you know and probably fix them 😊
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mia/0x0#79
No description provided.