Fixed: Naming Token Regex can fail on certain Cultures (#5855)

[common]
This commit is contained in:
Qstick 2021-02-02 21:45:13 -05:00 committed by GitHub
parent ad3ddd11cf
commit a0d2af54e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
@ -564,6 +566,24 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
.Should().Be("30 Rock - 30 Rock - S01E01 - Test");
}
[TestCase("en-US")]
[TestCase("fr-FR")]
[TestCase("az")]
[TestCase("tr-TR")]
public void should_replace_all_tokens_for_different_cultures(string culture)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
_movie.TmdbId = 124578;
_movie.Year = 2020;
GivenMediaInfoModel();
_namingConfig.StandardMovieFormat = "{Movie CleanTitle} ({Release Year}) [{Quality Title}] [tmdb-{TmdbId}] [{MediaInfo AudioCodec}]";
Subject.BuildFileName(_movie, _movieFile)
.Should().Be("South Park (2020) [HDTV-720p] [tmdb-124578] [DTS]");
}
[Test]
public void should_be_able_to_use_original_filename_only()
{

View File

@ -38,7 +38,7 @@ namespace NzbDrone.Core.Organizer
private readonly Logger _logger;
private static readonly Regex TitleRegex = new Regex(@"\{(?<prefix>[- ._\[(]*)(?<token>(?:[a-z0-9]+)(?:(?<separator>[- ._]+)(?:[a-z0-9]+))?)(?::(?<customFormat>[a-z0-9|]+))?(?<suffix>[- ._)\]]*)\}",
RegexOptions.Compiled | RegexOptions.IgnoreCase);
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
private static readonly Regex TagsRegex = new Regex(@"(?<tags>\{tags(?:\:0+)?})",
RegexOptions.Compiled | RegexOptions.IgnoreCase);