from os.path import splitext
import logging
+import uuid
_log = logging.getLogger(__name__)
try:
filename = request.files['file'].filename
+ # If the filename contains non ascii generate a unique name
+ if not all(ord(c) < 128 for c in filename):
+ filename = unicode(uuid.uuid4()) + splitext(filename)[-1]
+
# Sniff the submitted media to determine which
# media plugin should handle processing
media_type, media_manager = sniff_media(
entry.media_type = unicode(media_type)
entry.title = (
unicode(submit_form.title.data)
- or unicode(splitext(filename)[0]))
+ or unicode(splitext(request.files['file'].filename)[0]))
entry.description = unicode(submit_form.description.data)