Skip to content

Commit

Permalink
GITC-607: 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 367ddfe commit 7408cc3
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 @@ -1909,13 +1909,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 logo is present, validate that it is an 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 7408cc3

Please sign in to comment.