Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions mycodo/mycodo_flask/routes_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def send_note_attachment(filename):
file_path = os.path.join(PATH_NOTE_ATTACHMENTS, filename)
if file_path is not None:
try:
if os.path.abspath(file_path).startswith(PATH_NOTE_ATTACHMENTS):
if os.path.realpath(file_path).startswith(os.path.realpath(PATH_NOTE_ATTACHMENTS) + os.sep):
return send_file(file_path, as_attachment=True)
except Exception:
logger.exception("Send note attachment")
Expand Down Expand Up @@ -182,11 +182,11 @@ def camera_img_return_path(unique_id, img_type, filename):
return "Unknown Image Type"

path_file = os.path.join(path, filename)
if os.path.isfile(path_file) and os.path.abspath(path_file).startswith(path):
if os.path.isfile(path_file) and os.path.realpath(path_file).startswith(os.path.realpath(path) + os.sep):
return send_file(path_file, mimetype='image/jpeg')

path_file = f"/tmp/{filename}"
if os.path.exists(path_file) and os.path.abspath(path_file).startswith("/tmp"):
if os.path.exists(path_file) and os.path.realpath(path_file).startswith("/tmp" + os.sep):
return send_file(path_file, mimetype='image/jpeg')

elif function:
Expand Down Expand Up @@ -220,15 +220,15 @@ def camera_img_return_path(unique_id, img_type, filename):
return "Unknown Image Type"

path_file = os.path.join(path, filename)
if os.path.isfile(path_file) and os.path.abspath(path_file).startswith(path):
if os.path.isfile(path_file) and os.path.realpath(path_file).startswith(os.path.realpath(path) + os.sep):
if img_type == 'video':
return send_file(path_file, download_name=filename)
else:
return send_file(path_file, mimetype='image/jpeg')

path_file = f"/tmp/{filename}"
if (os.path.exists(path_file) and
os.path.abspath(path_file).startswith("/tmp")):
os.path.realpath(path_file).startswith("/tmp" + os.sep)):
if img_type == 'video':
return send_file(path_file, download_name=filename)
else:
Expand Down