Permalink
Browse files

Accept only valid image extensions.

  • Loading branch information...
James Socol
James Socol committed Dec 21, 2010
1 parent 06c8833 commit ad6411c92fc66fd7bfb298fc4fa501b4d4de09a6
Showing with 4 additions and 0 deletions.
  1. +4 −0 apps/games/forms.py
View
@@ -26,6 +26,10 @@ def clean_file(self):
if not file:
raise forms.ValidationError('You must upload an image!')
_, _, ext = file.name.rpartition('.')
if not ext.lower() in ('png', 'gif', 'jpg', 'jpeg'):
raise forms.ValidationError('Invalid file type!')
if file.size >> 10 > settings.SCREENSHOTS_MAX_SIZE:
msg = 'The image was too big (%i KB)! The limit is %i KB.'
raise forms.ValidationError(msg % (file.size >> 10,

0 comments on commit ad6411c

Please sign in to comment.