Don't try to match a null codec name (#784)

* Don't try to match a null codec name

* Add test
This commit is contained in:
ta264 2019-05-01 06:42:01 +01:00 committed by GitHub
parent 1955cd9f73
commit 541841d7b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -284,6 +284,12 @@ namespace NzbDrone.Core.Test.ParserTests
QualityParser.ParseQuality(title, null, 0).QualityDetectionSource.Should().Be(QualityDetectionSource.Extension);
}
[Test]
public void should_parse_null_quality_description_as_unknown()
{
QualityParser.ParseCodec(null, null).Should().Be(Codec.Unknown);
}
private void ParseAndVerifyQuality(string name, string desc, int bitrate, Quality quality, int sampleSize = 0)
{
var result = QualityParser.ParseQuality(name, desc, bitrate, sampleSize);

View File

@ -154,6 +154,11 @@ namespace NzbDrone.Core.Parser
public static Codec ParseCodec(string name, string origName)
{
if (name.IsNullOrWhiteSpace())
{
return Codec.Unknown;
}
var match = CodecRegex.Match(name);
if (!match.Success) { return Codec.Unknown; }