From f7118bebfd0a69c3dc90a5245b1d4d95bb2c900d Mon Sep 17 00:00:00 2001 From: Joe Rogers <1337joe@gmail.com> Date: Sat, 5 Mar 2022 12:37:29 +0100 Subject: [PATCH] Fix external file check for shorter names --- MediaBrowser.Providers/MediaInfo/MediaInfoResolver.cs | 3 ++- .../MediaInfo/MediaInfoResolverTests.cs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Providers/MediaInfo/MediaInfoResolver.cs b/MediaBrowser.Providers/MediaInfo/MediaInfoResolver.cs index 9338272079..39be405ec5 100644 --- a/MediaBrowser.Providers/MediaInfo/MediaInfoResolver.cs +++ b/MediaBrowser.Providers/MediaInfo/MediaInfoResolver.cs @@ -166,7 +166,8 @@ namespace MediaBrowser.Providers.MediaInfo foreach (var file in files) { var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.AsSpan()); - if (prefix.Equals(fileNameWithoutExtension[..prefix.Length], StringComparison.OrdinalIgnoreCase) + if (fileNameWithoutExtension.Length >= prefix.Length + && prefix.Equals(fileNameWithoutExtension[..prefix.Length], StringComparison.OrdinalIgnoreCase) && (fileNameWithoutExtension.Length == prefix.Length || _namingOptions.MediaFlagDelimiters.Contains(fileNameWithoutExtension[prefix.Length]))) { var externalPathInfo = _externalPathParser.ParseFile(file, fileNameWithoutExtension[prefix.Length..].ToString()); diff --git a/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs b/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs index 9bd02d956c..98b4a6ccf6 100644 --- a/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs +++ b/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs @@ -157,6 +157,7 @@ public class MediaInfoResolverTests } [Theory] + [InlineData("cover.jpg")] [InlineData("My.Video.mp3")] [InlineData("My.Video.png")] [InlineData("My.Video.txt")]