mirror of
https://github.com/Radarr/Radarr.git
synced 2025-04-23 22:17:15 -04:00
Prevent NullRef in naming when truncating a null Release Group
(cherry picked from commit 13e29bd257ccfccb09e66c940ffabeb6503c05b5)
This commit is contained in:
parent
d7b9b2ccb2
commit
41ff9352b9
1 changed files with 6 additions and 1 deletions
|
@ -327,7 +327,7 @@ namespace NzbDrone.Core.Organizer
|
|||
{
|
||||
tokenHandlers["{Original Title}"] = m => GetOriginalTitle(movieFile, multipleTokens);
|
||||
tokenHandlers["{Original Filename}"] = m => GetOriginalFileName(movieFile, multipleTokens);
|
||||
tokenHandlers["{Release Group}"] = m => Truncate(movieFile.ReleaseGroup, m.CustomFormat) ?? m.DefaultValue("Radarr");
|
||||
tokenHandlers["{Release Group}"] = m => movieFile.ReleaseGroup.IsNullOrWhiteSpace() ? m.DefaultValue("Radarr") : Truncate(movieFile.ReleaseGroup, m.CustomFormat);
|
||||
}
|
||||
|
||||
private void AddQualityTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Movie movie, MovieFile movieFile)
|
||||
|
@ -621,6 +621,11 @@ namespace NzbDrone.Core.Organizer
|
|||
|
||||
private string Truncate(string input, string formatter)
|
||||
{
|
||||
if (input.IsNullOrWhiteSpace())
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var maxLength = GetMaxLengthFromFormatter(formatter);
|
||||
|
||||
if (maxLength == 0 || input.Length <= Math.Abs(maxLength))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue