diff options
| author | Brian J. Murrell <brian@interlinx.bc.ca> | 2021-11-29 17:53:26 -0500 |
|---|---|---|
| committer | Brian J. Murrell <brian@interlinx.bc.ca> | 2021-11-29 17:53:26 -0500 |
| commit | 757970bfc17b0eb1566b45fbe700dcb16423b190 (patch) | |
| tree | 63fbc171621f5ec7ae156f341d9b1df37643deac /Emby.Server.Implementations/Library/PathExtensions.cs | |
| parent | a3a4689af22693b535e80b98624831866fda2a61 (diff) | |
| parent | c677b4f6b7f7e874097aa2cee866d9ed1e574178 (diff) | |
Merge remote-tracking branch 'origin/master' into HEAD
Diffstat (limited to 'Emby.Server.Implementations/Library/PathExtensions.cs')
| -rw-r--r-- | Emby.Server.Implementations/Library/PathExtensions.cs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/Library/PathExtensions.cs b/Emby.Server.Implementations/Library/PathExtensions.cs index 770cf6bb0..d5b855cdf 100644 --- a/Emby.Server.Implementations/Library/PathExtensions.cs +++ b/Emby.Server.Implementations/Library/PathExtensions.cs @@ -1,5 +1,3 @@ -#nullable enable - using System; using System.Diagnostics.CodeAnalysis; using MediaBrowser.Common.Providers; @@ -55,7 +53,7 @@ namespace Emby.Server.Implementations.Library /// <param name="path">The original path.</param> /// <param name="subPath">The original sub path.</param> /// <param name="newSubPath">The new sub path.</param> - /// <param name="newPath">The result of the sub path replacement</param> + /// <param name="newPath">The result of the sub path replacement.</param> /// <returns>The path after replacing the sub path.</returns> /// <exception cref="ArgumentNullException"><paramref name="path" />, <paramref name="newSubPath" /> or <paramref name="newSubPath" /> is empty.</exception> public static bool TryReplaceSubPath( @@ -96,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; } |
