aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/PathExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Library/PathExtensions.cs')
-rw-r--r--Emby.Server.Implementations/Library/PathExtensions.cs14
1 files changed, 8 insertions, 6 deletions
diff --git a/Emby.Server.Implementations/Library/PathExtensions.cs b/Emby.Server.Implementations/Library/PathExtensions.cs
index 6eaecff0f..86b8039fa 100644
--- a/Emby.Server.Implementations/Library/PathExtensions.cs
+++ b/Emby.Server.Implementations/Library/PathExtensions.cs
@@ -1,9 +1,5 @@
-#nullable enable
-
using System;
using System.Diagnostics.CodeAnalysis;
-using System.IO;
-using System.Text.RegularExpressions;
using MediaBrowser.Common.Providers;
namespace Emby.Server.Implementations.Library
@@ -98,8 +94,14 @@ namespace Emby.Server.Implementations.Library
// We have to ensure that the sub path ends with a directory separator otherwise we'll get weird results
// when the sub path matches a similar but in-complete subpath
var oldSubPathEndsWithSeparator = subPath[^1] == newDirectorySeparatorChar;
- if (!path.StartsWith(subPath, StringComparison.OrdinalIgnoreCase)
- || (!oldSubPathEndsWithSeparator && path[subPath.Length] != newDirectorySeparatorChar))
+ if (!path.StartsWith(subPath, StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+
+ if (path.Length > subPath.Length
+ && !oldSubPathEndsWithSeparator
+ && path[subPath.Length] != newDirectorySeparatorChar)
{
return false;
}