mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-23 06:45:19 -07:00
Fixed: Inserting literal { or } in renaming format using {{ or }}
Closes #1267
This commit is contained in:
parent
cabfae1f59
commit
36b9e585ef
2 changed files with 23 additions and 1 deletions
|
@ -505,6 +505,28 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||||
.Should().Be("Linkin Park - Hybrid Theory - 06 - City Sushi [MP3-256]");
|
.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]
|
[Test]
|
||||||
public void use_file_name_when_sceneName_is_null()
|
public void use_file_name_when_sceneName_is_null()
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace NzbDrone.Core.Organizer
|
||||||
private readonly ICached<AbsoluteTrackFormat[]> _absoluteTrackFormatCache;
|
private readonly ICached<AbsoluteTrackFormat[]> _absoluteTrackFormatCache;
|
||||||
private readonly Logger _logger;
|
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);
|
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
public static readonly Regex TrackRegex = new Regex(@"(?<track>\{track(?:\:0+)?})",
|
public static readonly Regex TrackRegex = new Regex(@"(?<track>\{track(?:\:0+)?})",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue