Skip to content

Commit 23a8192

Browse files
committed
Added exception catching to the photo endpoint, for cases where conversion fails (we just had one case of RGBA to JPEG didn't work).
- Legacy-Id: 18697
1 parent 49f6f89 commit 23a8192

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

ietf/person/views.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ def photo(request, email_or_name):
9999
img = Image.open(person.photo)
100100
img = img.resize((size, img.height*size//img.width))
101101
bytes = BytesIO()
102-
img.save(bytes, format='JPEG')
103-
return HttpResponse(bytes.getvalue(), content_type='image/jpg')
102+
try:
103+
img.save(bytes, format='JPEG')
104+
return HttpResponse(bytes.getvalue(), content_type='image/jpg')
105+
except OSError:
106+
raise Http404
104107

105108

106109
@role_required("Secretariat")

0 commit comments

Comments
 (0)