[PR #9219] Add a way to handle more invalid characters when sanitizing a filename #12025

Closed
opened 2026-02-07 06:48:41 +03:00 by OVERLORD · 0 comments
Owner

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

**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](https://www.themoviedb.org/collection/661026)). I traced the issue to Path.GetInvalidFileNameChars() not including all possible problematic characters on all filesystems, as mentioned in [the remarks of the doc](https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getinvalidfilenamechars?view=net-7.0#remarks). 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
OVERLORD added the pull-request label 2026-02-07 06:48:41 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#12025