mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-16 05:43:54 +03:00
[PR #9219] Add a way to handle more invalid characters when sanitizing a filename #12025
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/jellyfin/jellyfin/pull/9219
State: closed
Merged: Yes
Changes
GetValidFilename() Does not properly work for some filesystems.
I noticed the issue because the tmdb boxsets plugin failed to create collections when there was a colon in the collection name (example collection).
I traced the issue to Path.GetInvalidFileNameChars() not including all possible problematic characters on all filesystems, as mentioned in the remarks of the doc.
In my case (config on an external ntfs drive on ubuntu 22.04 through docker), the colon prevented the collection directory creation, but wasn't returned by the function.
As it would be impractical to rewrite a better equivalent of the function, I chose to simply add a manually defined array containing the problematic char, this way more can be easily added if more edge cases are discovered.
Also, the alternative option Path.GetInvalidPathChars() has the same problem, so it wouldn't help, but there's no other sane alternative from what I've seen...
Issues
Didn't end up creating an issue since I found the cause quickly enough, but I can if needed.
EDIT:
Fixes #2370