mirror of https://github.com/lidarr/Lidarr
Fixed: Inserting literal { or } in renaming format using {{ or }}
Closes #1267
This commit is contained in:
parent
cabfae1f59
commit
86130751c2
|
@ -505,6 +505,28 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
|||
.Should().Be("Linkin Park - Hybrid Theory - 06 - City Sushi [MP3-256]");
|
||||
}
|
||||
|
||||
[TestCase("Some Escaped {{ String", "Some Escaped { String")]
|
||||
[TestCase("Some Escaped }} String", "Some Escaped } String")]
|
||||
[TestCase("Some Escaped {{Artist Name}} String", "Some Escaped {Artist Name} String")]
|
||||
[TestCase("Some Escaped {{{Artist Name}}} String", "Some Escaped {Linkin Park} String")]
|
||||
public void should_escape_token_in_format(string format, string expected)
|
||||
{
|
||||
_namingConfig.StandardTrackFormat = format;
|
||||
|
||||
Subject.BuildTrackFileName(new List<Track> { _track1 }, _artist, _album, _trackFile)
|
||||
.Should().Be(expected);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_escape_token_in_title()
|
||||
{
|
||||
_namingConfig.StandardTrackFormat = "Some Unescaped {Artist Name} String";
|
||||
_artist.Name = "My {Quality Full} Title";
|
||||
|
||||
Subject.BuildTrackFileName(new List<Track> { _track1 }, _artist, _album, _trackFile)
|
||||
.Should().Be("Some Unescaped My {Quality Full} Title String");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void use_file_name_when_sceneName_is_null()
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace NzbDrone.Core.Organizer
|
|||
private readonly ICached<AbsoluteTrackFormat[]> _absoluteTrackFormatCache;
|
||||
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>[- ._)\]]*)\}",
|
||||
private static readonly Regex TitleRegex = new Regex(@"(?<escaped>\{\{|\}\})|\{(?<prefix>[- ._\[(]*)(?<token>(?:[a-z0-9]+)(?:(?<separator>[- ._]+)(?:[a-z0-9]+))?)(?::(?<customFormat>[a-z0-9]+))?(?<suffix>[- ._)\]]*)\}",
|
||||
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
public static readonly Regex TrackRegex = new Regex(@"(?<track>\{track(?:\:0+)?})",
|
||||
|
|
Loading…
Reference in New Issue