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

Unsanitized filenames #340

Open
OmarAHex opened this issue Apr 5, 2024 · 4 comments
Open

Unsanitized filenames #340

OmarAHex opened this issue Apr 5, 2024 · 4 comments
Assignees
Labels
bug for issue

Comments

@OmarAHex
Copy link

OmarAHex commented Apr 5, 2024

Provide environment information

Python 3.11.5 on windows

What OS are you using?

Windows 11

Describe the Bug

When downloading a folder, if any of the filenames in the folder contains an asterisk, gdown attempts to create a tempfile without changing it's base name to remove invalid characters such as /:?<>|
This is the error message
OSError: [Errno 22] Invalid argument: 'C:\Users\....filename
.pdfo9gwxp5ltmp'

I'm specifying the tempfile because that's where the error pops up, not sure if the final file would have the same problem.

Expected Behavior

No response

To Reproduce

No response

@OmarAHex OmarAHex added the bug for issue label Apr 5, 2024
@OmarAHex
Copy link
Author

OmarAHex commented Apr 5, 2024

Another note, google drive allows slashes in file names, meaning by the time the download function receives the output path it is impossible to tell whether that slash is part of a file name or represents a folder, so atleast some part of the sanitization would need to happen in the download_folder file. (The error raised here is related to trying to write to a nonexistant folder)

@OmarAHex
Copy link
Author

OmarAHex commented Apr 6, 2024

Also, line 185 in download_folder.py does "file.name.replace(osp.sep, '_')"
but this is not sufficient for windows
on windows, osp.sep is "\", but "/" is also a valid separator, which gdown ignores, I think this entire issue could be resolved by replacing that line of code with a proper sanitization function

@wkentaro
Copy link
Owner

@OmarAHex Can you give me an example so that I can reproduce?

@wkentaro wkentaro self-assigned this May 12, 2024
@OmarAHex
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug for issue
Projects
None yet
Development

No branches or pull requests

2 participants