Skip to content
Merged
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: 10 additions & 0 deletions atlassian/confluence/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import re
import time
import warnings
from typing import cast

import requests
Expand Down Expand Up @@ -1569,6 +1570,15 @@ def download_attachments_from_page(self, page_id, path=None, start=0, limit=50,
file_obj = io.BytesIO(response)
downloaded_files[file_name] = file_obj
else:
# Sanitize filename if needed
if re.search(r'[<>:"/\\|?*\x00-\x1F]', file_name):
sanitized = re.sub(r'[<>:"/\\|?*\x00-\x1F]', '_', file_name)
warnings.warn(
f"File name '{file_name}' contained invalid characters and was renamed to '{sanitized}'.",
UserWarning
)
file_name = sanitized
file_path = os.path.join(path, file_name)
# Save file to disk
file_path = os.path.join(path, file_name)
with open(file_path, "wb") as file:
Expand Down