Skip to content

Commit

Permalink
GITC-609: Fix validation of logo (check that it isn't empty/None first)
Browse files Browse the repository at this point in the history
  • Loading branch information
nutrina committed Nov 25, 2021
1 parent 5922e4a commit 28fba73
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1915,13 +1915,15 @@ def grant_new(request):
token_symbol = request.POST.get('token_symbol', 'Any Token')
logo = request.FILES.get('logo', None)

try:
im = Image.open(logo)
im.verify()
except IOError as e:
# logo is not an image file
response['message'] = 'error: invalid logo file'
return JsonResponse(response)
if logo:
# If a logo has been specified, verify that it is a valid image
try:
im = Image.open(logo)
im.verify()
except IOError as e:
# logo is not an image file
response['message'] = 'error: invalid logo file'
return JsonResponse(response)

metdata = json.loads(request.POST.get('receipt', '{}'))
team_members = request.POST.getlist('team_members[]')
Expand Down

0 comments on commit 28fba73

Please sign in to comment.