Merge pull request #7403 from 1337joe/fix-external-file-prefix-check

This commit is contained in:
Cody Robibero 2022-03-05 12:43:29 -07:00 committed by GitHub
commit 4791d56f6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -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());

View File

@ -157,6 +157,7 @@ public class MediaInfoResolverTests
}
[Theory]
[InlineData("cover.jpg")]
[InlineData("My.Video.mp3")]
[InlineData("My.Video.png")]
[InlineData("My.Video.txt")]