Skip to content

Commit

Permalink
Ensure that there is always an internal path and wrap it always in quote
Browse files Browse the repository at this point in the history
  • Loading branch information
derneuere committed May 24, 2023
1 parent 75036ec commit 7860582
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions api/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,11 @@ def get(self, request, path, fname, format=None):
"/nextcloud_media/", "/nextcloud_original/"
)
internal_path = "/nextcloud_original" + photo.main_file.path[21:]
if photo.main_file.path.startswith("/data/"):
else:
internal_path = "/original" + photo.main_file.path[5:]

internal_path = quote(internal_path)

# grant access if the requested photo is public
if photo.public:
response = HttpResponse()
Expand Down Expand Up @@ -488,7 +490,7 @@ def get(self, request, path, fname, format=None):
mime = magic.Magic(mime=True)
filename = mime.from_file(photo.main_file.path)
response["Content-Type"] = filename
response["X-Accel-Redirect"] = quote(internal_path)
response["X-Accel-Redirect"] = internal_path
return response
else:
for album in photo.albumuser_set.only("shared_to"):
Expand Down

0 comments on commit 7860582

Please sign in to comment.