Remove validation check for old file path during rename#23871
Remove validation check for old file path during rename#23871bwrightkc wants to merge 2 commits intoqbittorrent:masterfrom
Conversation
remove check for validity of old file path - causes issue where disallowed character (ex colon on macOS) cannot be renamed as the file path would be "invalid", which is a main reason one may need to rename that filename.
I wonder how such a torrent can appear at all? As far as I know, libtorrent cleans inappropriate paths when adding a torrent. Are you saying that it doesn't work in some cases?
How did you test it on Windows? Do you have some kind of .torrent file that contains invalid characters in the file paths? Then could you provide it for testing? |
Good question, looking at it it doesn't seem like libtorrent cleans filenames on Linux or macOS looking in torrent_info.cpp at line 93 #ifdef TORRENT_WINDOWS
// On windows, both the filesystem and the operating system impose
// restrictions.
static const char invalid_chars[] = "?<>\"|\b*:";
#elif defined TORRENT_ANDROID
// The Android kernel probably has similar restrictions as Linux (i.e.
// very few) but it appears some user-space system libraries impose
// additional restrictions, and it's probably more common to use FAT32
// style filesystems, which also further restricts valid characters
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/os/FileUtils.java;l=997?q=isValidFatFilenameChar
static const char invalid_chars[] = "\"*:<>?|";
#else
static const char invalid_chars[] = "";
Probably worth fixing in both qBittorrent and libtorrent (I'm going to take a closer look at that today as it might be smart to filter out /: on the libtorrent end to prevent any macOS issues there). However, on the qBittorrent end, I think it's just simple enough to allow the user to rename the file regardless of any invalid characters in the name.
Apologies, I shouldn't have put Windows - I compiled with the patch on Windows to verify that I didn't break anything, but the issue I was only able to recreate on macOS. |
|
xref: #23386 |
Closes #23834.
What: Remove validation check for old file path during rename.
Why: The previous validation prevented renaming files whose existing
paths contained disallowed characters (e.g., ":" on macOS).
This made it impossible to rename files specifically because
their current names were invalid.
Removing this check allows invalid filenames and folder names
to be corrected.
Tested on: macOS, Windows 11.