Skip to content

Commit 29b1dd2

Browse files
authored
File Path Access: Prevent exception for non existent paths (#12976)
1 parent a51d0e2 commit 29b1dd2

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

dojo/views.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,7 @@ def manage_files(request, oid, obj_type):
198198
@login_required
199199
def protected_serve(request, path, document_root=None, *, show_indexes=False):
200200
"""Serve the file only after verifying the user is supposed to see the file."""
201-
file = FileUpload.objects.get(file=path)
202-
if not file:
203-
raise Http404
201+
file = get_object_or_404(FileUpload, file=path)
204202
object_set = list(file.engagement_set.all()) + list(file.test_set.all()) + list(file.finding_set.all())
205203
# Determine if there is an object to query permission checks from
206204
if len(object_set) == 0:

0 commit comments

Comments
 (0)