Skip to content

[Confluence] Sanitize attachment filenames to prevent download failures #1549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AntonioContrerasO
Copy link

Pull Request Description

This PR improves the download_attachments_from_page method by adding filename sanitization to handle invalid characters in attachment filenames that can cause download failures on certain file systems.

While building a component for Confluence and scraping one of the spaces, I noticed that some files could not be downloaded because their names contained invalid characters (such as <>:"/\|?* and control characters) which are not allowed on Windows and other platforms.

To address this, the code now replaces these invalid characters with underscores (_) to ensure files can be saved without errors. Additionally, a warning is issued to notify users when a filename has been modified due to sanitization.

As an example, when running on macOS, I encountered a filename like:

image2017-9-24 20:1:28.png

which, after sanitization for Windows compatibility, would be handled gracefully by the refactored code. The refactor aims to be general and platform-agnostic, but focused on preventing errors commonly seen on Windows.

This is my first pull request to a major open-source library, so I welcome any comments, suggestions, or recommendations for improving the implementation or code style. I’m happy to make any necessary adjustments to meet the project’s standards.

Thanks for reading.

…ystem characters with underscores to prevent download errors and warn users of renaming
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant