Skip to content

Commit

Permalink
bugfix: Ensure history file is in history directory when deleting the…
Browse files Browse the repository at this point in the history
… file.
  • Loading branch information
GaiZhenbiao committed Sep 18, 2024
1 parent 919222d commit 01f43a3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/models/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,9 @@ def delete_chat_history(self, filename):
# if user access control is not enabled, user_name is empty, don't check
assert os.path.basename(os.path.dirname(history_file_path)) == self.user_name or self.user_name == ""
assert os.path.basename(os.path.dirname(md_history_file_path)) == self.user_name or self.user_name == ""
# check if history file path is in history directory
assert os.path.realpath(history_file_path).startswith(os.path.realpath(HISTORY_DIR))
assert os.path.realpath(md_history_file_path).startswith(os.path.realpath(HISTORY_DIR))
try:
os.remove(history_file_path)
os.remove(md_history_file_path)
Expand Down

0 comments on commit 01f43a3

Please sign in to comment.