Better validation for Imdb Ids from lists

Fixes #5674
pull/5710/head
Qstick 4 years ago
parent 99b75a3089
commit 88ec106ec6

@ -162,6 +162,7 @@ namespace NzbDrone.Core.Test.ParserTests
parsed.ImdbId.Should().Be(imdb); parsed.ImdbId.Should().Be(imdb);
} }
[TestCase("asfd", null)]
[TestCase("123", "tt0000123")] [TestCase("123", "tt0000123")]
[TestCase("1234567", "tt1234567")] [TestCase("1234567", "tt1234567")]
[TestCase("tt1234567", "tt1234567")] [TestCase("tt1234567", "tt1234567")]

@ -125,6 +125,13 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
public Movie GetMovieByImdbId(string imdbId) public Movie GetMovieByImdbId(string imdbId)
{ {
imdbId = Parser.Parser.NormalizeImdbId(imdbId);
if (imdbId == null)
{
return null;
}
var httpRequest = _radarrMetadata.Create() var httpRequest = _radarrMetadata.Create()
.SetSegment("route", "movie/imdb") .SetSegment("route", "movie/imdb")
.Resource(imdbId.ToString()) .Resource(imdbId.ToString())

@ -357,6 +357,13 @@ namespace NzbDrone.Core.Parser
public static string NormalizeImdbId(string imdbId) public static string NormalizeImdbId(string imdbId)
{ {
var imdbRegex = new Regex(@"^(\d{1,10}|(tt)\d{1,10})$");
if (!imdbRegex.IsMatch(imdbId))
{
return null;
}
if (imdbId.Length > 2) if (imdbId.Length > 2)
{ {
imdbId = imdbId.Replace("tt", "").PadLeft(7, '0'); imdbId = imdbId.Replace("tt", "").PadLeft(7, '0');

Loading…
Cancel
Save