Skip to content

Commit

Permalink
fix path traversal issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzay-G committed Mar 5, 2022
1 parent 5db3031 commit dedc5a0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion archivy/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ def create(contents, title, path=""):
max_filename_length = 255
if len(filename + ".md") > max_filename_length:
filename = filename[0 : max_filename_length - 3]
path_to_md_file = data_dir / path.strip("/") / f"{filename}.md"
if not is_relative_to(data_dir / path, data_dir):
path = ""
path_to_md_file = data_dir / path / f"{filename}.md"
with open(path_to_md_file, "w", encoding="utf-8") as file:
file.write(contents)

Expand Down

0 comments on commit dedc5a0

Please sign in to comment.