Commit 457d171c authored by jvoisin's avatar jvoisin

Improve the display of supported formats

- Show the extension instead of the mimetype
- Sort the results
parent 769bafac
Pipeline #23183 passed with stages
in 1 minute and 16 seconds
import os
import hashlib
import hmac
import mimetypes as mtype
from libmat2 import parser_factory
......@@ -60,7 +61,9 @@ def upload_file():
mimetypes = set()
for parser in parser_factory._get_parsers():
mimetypes = mimetypes | parser.mimetypes
mimetypes |= set(map(mtype.guess_extension, parser.mimetypes))
# since `guess_extension` might return `None`, we need to filter it out
mimetypes = sorted(filter(None, mimetypes))
if request.method == 'POST':
if 'file' not in request.files: # check if the post request has the file part
......
......@@ -21,8 +21,8 @@ class FlaskrTestCase(unittest.TestCase):
def test_check_mimetypes(self):
rv = self.app.get('/')
self.assertIn(b'application/zip', rv.data)
self.assertIn(b'audio/x-flac', rv.data)
self.assertIn(b'.torrent', rv.data)
self.assertIn(b'.ods', rv.data)
def test_get_download_dangerous_file(self):
rv = self.app.get('/download/1337/\..\filename')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment