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

[Windows] Folder Name Sanitization Needed #647

Open
chrsmlls333 opened this issue Mar 19, 2020 · 2 comments
Open

[Windows] Folder Name Sanitization Needed #647

chrsmlls333 opened this issue Mar 19, 2020 · 2 comments

Comments

@chrsmlls333
Copy link

Similar to #545 , there is an issue with tag variables that contain trailing ellipsis (...) being used for folder names and creating damaged, undeletable folders on Windows.

I am not sure how slashes and other non-permitted characters are handled or removed from new filenames, but there may need to be a final cleaning step (for each OS separately) to make sure its a valid path.

Specifically, here C:\Temp\Title...\Image1.jpg is not permitted, yet gallery-dl creates these folders with trailing dots and they can only be removed by the cmd prompt.

Please let me know if a filter is already built in or can be augmented to handle this exception. Thanks! Working great otherwise!

@mikf
Copy link
Owner

mikf commented Mar 19, 2020

Trailing dots are now getting removed from directory names (9159cb8), but I've taken another look at https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file and realized that their is still quite a lot to be done to cover all cases.

There are two "built in" options that kind of deal with stuff like this, but they wouldn't really have helped here: path-restrict and path-remove. They apply to both directory and file names, and there is no good way to use them to remove characters from the end of a string.

@chrsmlls333
Copy link
Author

chrsmlls333 commented Mar 20, 2020

Thanks for your prompt work on this!

Found a library here: https://pypi.org/project/pathvalidate/
Im much more familiar with node's built-in path join function

Your method of building by path segment seems sound to me, perhaps replace those path-restrict and path-remove with a unified validation option, and operate a function across each segment as its built. I would also add a catch for if the input is all unpermitted characters.

My main question I guess is, is there a reason why this should be an option? Should generated paths not be both unix- and windows-safe by default?

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

No branches or pull requests

2 participants