From 28fba73438a92f52c79e424ca3dffaee5e7b9ddc Mon Sep 17 00:00:00 2001 From: Gerald Iakobinyi-Pich Date: Thu, 25 Nov 2021 18:06:57 +0200 Subject: [PATCH] GITC-609: Fix validation of logo (check that it isn't empty/None first) --- app/grants/views.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/grants/views.py b/app/grants/views.py index 8c8b9609180..9ba8deebbfb 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -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[]')