Skip to content

Commit

Permalink
Merge pull request #2043 from bensteinberg/image-uuid
Browse files Browse the repository at this point in the history
Suppress error for non-UUID in image route
  • Loading branch information
bensteinberg authored Mar 20, 2024
2 parents 4a6dabd + c3c883e commit e997b79
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions web/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3280,5 +3280,10 @@ def view_image(request, image_uuid):
Redirect to S3 with temp creds.
"""
saved_image = get_object_or_404(SavedImage.objects.filter(external_id=image_uuid))
return redirect(saved_image.image.url)
try:
assert uuid.UUID(image_uuid)
saved_image = get_object_or_404(SavedImage.objects.filter(external_id=image_uuid))
return redirect(saved_image.image.url)
except ValueError:
# image_uuid is not a UUID
raise Http404

0 comments on commit e997b79

Please sign in to comment.