-
-
Notifications
You must be signed in to change notification settings - Fork 123
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
[Bug Report] Sanitize paths (folder/directories) for downloads from plugins #212
Comments
I agree and thanks for the suggestion! Let me work on it when I have the time, and PRs are always welcome. |
This is the filename pre-processing rule I ended up using, which replaces whitespaces, dots ( I don't think the other special characters you listed matter too much, because when accessing the files/folders (e.g., through |
It seems a little bit harsh(?) to replace all special characters to underscores. How about using https://github.com/szTheory/zaru_crystal instead? Hope there would be an option to turn off Windows filename filter. |
@Leeingnyo Sorry not sure I understand. Isn't the zaru shard even "harsher"? It sanitizes more special characters than we do, and it does so by simply removing them. |
Actually, I just want to keep whitespaces as whitespaces :) and dots as dots, too. They remove
The option
or (It's getting complicated) sanitize_filename_rules:
- filter-windows-illegal
- trim whitespaces at start and end
- collapse-whitespaces
- [other-optional-rule] |
The problem with dots is that for example you can have For WSL, does the standard UNIX filename rules apply? Or does it use the Windows rules? |
But I guess we can keep whitespaces. Just need to trim and collapse them, and replace them with the standard whitespace ( |
Yes I agree that we should avoid the WSL follows UNIX's one in their environment, but the files can be accessed by Windows Explorer (seems as a broken file, causes some strange actions in Windows). Since I use symlinks NTFS drives for the Mango library running in WSL2, downloaded files by plugin can be easily accessed in Windows. |
@Leeingnyo Makes sense 👍 I will update the PR. |
Hi there! The issue has been fixed in v0.24.0. Thanks for the bug report! |
Describe the bug
I tried to download a manga through a plugin, and it worked, except that the created folder looks something like this:
"HOT\n\t\t\t\t Manga"
In theory, Linux does not have restrictions on the names of directories, but this causes problems with for example commands. (could not
cd
into the directory or remove it).I was able to remove it, by using python, where I did something like this:
This solved the issue for me, but I am familiar with programming and I do not think that everyone is able to do this. (most people will end up with folders they can not remove?)
I would suggest applying the following rules to the directory/file-names:
0x00
to0x1F
, see ASCII Table)" * : < > ? / \ | ~ # { }
.
)Source 1
Source 2
I think some above-mentioned rules are already performed by your code.
I would apply the rules by replacing each forbidden character with a space and then applying this regex:
string.replace("\\s\\s+", " ")
The text was updated successfully, but these errors were encountered: