Handle empty file names.

This commit is contained in:
Julien Palard 2020-01-06 22:31:59 +01:00
parent 19c44f4100
commit 2ffbe5d7dc

View File

@ -142,7 +142,7 @@ def save_post(category, timestamp, admin, form, files):
if 'image' in files:
post_image = files['image']
filename = secure_filename(post_image.filename)
filename = secure_filename(post_image.filename) or "image.jpg"
post_image.save(str(post.parent / filename))
element = ElementTree.SubElement(tree, 'image')
element.text = filename