Opened 9 years ago
Last modified 9 years ago
#5328 in_progress enhancement
White/blacklisting mimetypes in attachments and check file size
Reported by: | molgrum | Owned by: | molgrum |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | programming | Keywords: | whitelist, blacklist, mimetype, mimetypes, attachment, attachments |
Cc: | Parent Tickets: |
Description
I have working (non-elegant) code working for doing a white/blacklist of mimetypes. Also checks max_file_size parameter!
Attachments (2)
Change History (11)
by , 9 years ago
Attachment: | 0001-Added-support-for-blacklisting-whitelisting-mimetype.patch added |
---|
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Status: | new → review |
---|
by , 9 years ago
Attachment: | 0001-Fixed-so-that-HTML-is-displayed-instead-of-a-popup.patch added |
---|
comment:3 by , 9 years ago
Just FYI, you should apply both patches in the order they were submitted. Sorry for the inconvenience but I'm fresh at GIT!
comment:4 by , 9 years ago
To add multi-line parameters into mediagoblin.ini (which you probably want to do when listing many mimetypes), read this: http://www.voidspace.org.uk/python/configobj.html#config-files
comment:5 by , 9 years ago
Milestone: | → 0.9.0 |
---|
The general idea here looks good; I agree that we should provide a good way to blacklist/whitelist based on mimetype. Nonetheless, this needs some work:
- A lot of divergences from PEP-8, please read up!
- UNSAFE_MIMETYPES / SAFE_MIMETYPES defined, then immediately has its value replaced unconditionally. So why not just define it once each?
- not sure what
bMimeAllowed
means or does? - The body of the conditionals for whitelist/blacklist appears identical, so maybe you could group the conditional check to something like:
if (whitelist_check_here() OR blacklist_check_here()): body
- tests are needed, I think
I think I need to wrap my head around the JS changes a bit more, but that's on me, not you.
Doing a check in JS before we hit the server is a great idea to reduce waiting on a big upload that doesn't go through!
comment:6 by , 9 years ago
Milestone: | 0.9.0 |
---|
comment:7 by , 9 years ago
Type: | defect → enhancement |
---|
comment:8 by , 9 years ago
bin/py.test --boxed --cov-report=term-missing --cov=mediagoblin mediagoblin/tests
shows that the test are not broken (which is good ;-) but also shows that the tests do not cover the modified files:
mediagoblin/edit/views.py 217 87 60% 59, 79, 96, 107-111, 116-214, 232-233, 243, 256, 258-260, 291-300, 313-333, 360-365, 375-419, 432, 461, 478, 493, 538-539
comment:9 by , 9 years ago
Owner: | set to |
---|---|
Status: | review → in_progress |
The non-elegant part is the javascript code that does an alert() instead of adding HTML.