Run pre-commit

This commit is contained in:
gagb
2024-12-18 11:46:39 -08:00
parent 6e4caac70d
commit 5fc70864f2

View File

@@ -1144,8 +1144,13 @@ class ZipConverter(DocumentConverter):
# Safeguard against path traversal
for member in zipObj.namelist():
member_path = os.path.normpath(os.path.join(extraction_dir, member))
if not os.path.commonprefix([extraction_dir, member_path]) == extraction_dir:
raise ValueError(f"Path traversal detected in zip file: {member}")
if (
not os.path.commonprefix([extraction_dir, member_path])
== extraction_dir
):
raise ValueError(
f"Path traversal detected in zip file: {member}"
)
# Extract all files safely
zipObj.extractall(path=extraction_dir)