소스 검색

Add a way to add more invalid characters when sanitizing a filename

Ronan Charles-Lorel 2 년 전
부모
커밋
a2ac791bb7
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      Emby.Server.Implementations/IO/ManagedFileSystem.cs

+ 3 - 1
Emby.Server.Implementations/IO/ManagedFileSystem.cs

@@ -294,7 +294,9 @@ namespace Emby.Server.Implementations.IO
         /// <exception cref="ArgumentNullException">The filename is null.</exception>
         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)
             {