Skip to content

Commit

Permalink
use stricter rules for what filenames are valid on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Jan 27, 2025
1 parent 06a55f7 commit 44f19a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

2.0.11 released

* use stricter rules for what filenames are valid on Android
* fix applying IP filter to DHT traffic (HanabishiRecca)
* fix race condition when cancelling requests after becoming a seed
* fix performance bug in the file pool, evicting MRU instead of LRU (HanabishiRecca)
Expand Down
12 changes: 12 additions & 0 deletions src/torrent_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,22 @@ namespace libtorrent {

namespace {

// Which characters are valid is primarily determined by the
// filesystem, so this logic is an approximation. Note that forward- and
// backslash are filtered unconditionally and separately from this function.
bool valid_path_character(std::int32_t const c)
{
#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[] = "";
#endif
Expand Down

0 comments on commit 44f19a6

Please sign in to comment.