From a2ac791bb779297bedb608825602912228d415c1 Mon Sep 17 00:00:00 2001 From: Ronan Charles-Lorel Date: Tue, 31 Jan 2023 15:20:57 +0100 Subject: [PATCH] Add a way to add more invalid characters when sanitizing a filename --- Emby.Server.Implementations/IO/ManagedFileSystem.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs index 55f384ae8f..9b8831a1fe 100644 --- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs @@ -294,7 +294,9 @@ namespace Emby.Server.Implementations.IO /// The filename is null. public string GetValidFilename(string filename) { - var invalid = Path.GetInvalidFileNameChars(); + //necessary because (as per the doc) GetInvalidFileNameChars is not exhaustive and may not return all invalid chars, which creates issues + char[] genericInvalidChars = {':'}; + var invalid = Path.GetInvalidFileNameChars().Concat(genericInvalidChars).ToArray(); var first = filename.IndexOfAny(invalid); if (first == -1) {