aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/IO
diff options
context:
space:
mode:
authorRonan Charles-Lorel <ronan.charleslorel@gmail.com>2023-06-29 15:21:39 +0200
committerGitHub <noreply@github.com>2023-06-29 15:21:39 +0200
commit46763b7661948b463303fd5b12831a146e987886 (patch)
treef057049ea436e51dfc1d5e897495541f6d559224 /Emby.Server.Implementations/IO
parente108183b138552013bbfd13c36937481228eb9e6 (diff)
Remove call to Path.GetInvalidFileNameChars
Superseded by a static char list to avoid platform-dependent issues
Diffstat (limited to 'Emby.Server.Implementations/IO')
-rw-r--r--Emby.Server.Implementations/IO/ManagedFileSystem.cs11
1 files changed, 8 insertions, 3 deletions
diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs
index 60ab668cd..e9e75166b 100644
--- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs
+++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs
@@ -275,9 +275,14 @@ namespace Emby.Server.Implementations.IO
/// <exception cref="ArgumentNullException">The filename is null.</exception>
public string GetValidFilename(string filename)
{
- // 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();
+ // using a character list instead of GetInvalidFileNameChars, as it is not exhaustive and may not return all invalid chars
+ char[] invalid = {
+ '\"', '<', '>', '|', '\0',
+ (char)1, (char)2, (char)3, (char)4, (char)5, (char)6, (char)7, (char)8, (char)9, (char)10,
+ (char)11, (char)12, (char)13, (char)14, (char)15, (char)16, (char)17, (char)18, (char)19, (char)20,
+ (char)21, (char)22, (char)23, (char)24, (char)25, (char)26, (char)27, (char)28, (char)29, (char)30,
+ (char)31, ':', '*', '?', '\\', '/'
+ };
var first = filename.IndexOfAny(invalid);
if (first == -1)
{