Skip to content
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

Error in download_attachments_from_page() with some file names #1355

Open
Psancs05 opened this issue Mar 20, 2024 · 3 comments
Open

Error in download_attachments_from_page() with some file names #1355

Psancs05 opened this issue Mar 20, 2024 · 3 comments

Comments

@Psancs05
Copy link

Hi!

Using the method download_attachments_from_page() raises an exception when the filename is not sanitize
Eg: image2019-9-13 11:51:31.png this file raises an error, I believe that is caused by the colons (:)

@gkowalc
Copy link
Contributor

gkowalc commented Mar 20, 2024

which instance do you use? DC or cloud (if DC which version). Is it jira or confluence?
Also if possible, provide complete error trace.

@Psancs05
Copy link
Author

I think that it is not related to the client. Looking into the code I found this in atlassian/confluence.py:

for attachment in attachments:
  file_name = attachment["title"]
  if not file_name:
      file_name = attachment["id"]  # if the attachment has no title, use attachment_id as a filename

Line 1338, in the download_attachments_from_page() definition.
In the code the file name is used exactly as it is defined in Confluence, but some special characters (like colons) can cause an error in the filesystem. I have used a regexp in my local package to sanitize the file name and it seem to solve the problem

@gkowalc
Copy link
Contributor

gkowalc commented Mar 22, 2024

On macOS host, it seems to be fine. Are you using a Windows host? According to https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file, a colon shouldn't be used for files or directory names. Therefore, I don't think the problem is with the library code. I can add a small comment to the code with a warning.

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

No branches or pull requests

2 participants