Fixed: Escape Characters as needed for *znab queries

Closes #4788
This commit is contained in:
bakerboy448 2022-04-09 23:16:20 -05:00 committed by GitHub
parent 5a08d5dc24
commit f678775e5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 1 deletions

View File

@ -339,5 +339,40 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
pageTier2.Url.Query.Should().NotContain("rid=10");
pageTier2.Url.Query.Should().Contain("q=");
}
[Test]
public void should_encode_raw_title()
{
_capabilities.SupportedTvSearchParameters = new[] { "q", "season", "ep" };
_capabilities.TvTextSearchEngine = "raw";
_singleEpisodeSearchCriteria.SceneTitles[0] = "Edith & Little";
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
results.Tiers.Should().Be(1);
var pageTier = results.GetTier(0).First().First();
pageTier.Url.Query.Should().Contain("q=Edith%20%26%20Little");
pageTier.Url.Query.Should().NotContain(" & ");
pageTier.Url.Query.Should().Contain("%26");
}
[Test]
public void should_use_clean_title_and_encode()
{
_capabilities.SupportedTvSearchParameters = new[] { "q", "season", "ep" };
_capabilities.TvTextSearchEngine = "sphinx";
_singleEpisodeSearchCriteria.SceneTitles[0] = "Edith & Little";
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
results.Tiers.Should().Be(1);
var pageTier = results.GetTier(0).First().First();
pageTier.Url.Query.Should().Contain("q=Edith%20and%20Little");
pageTier.Url.Query.Should().Contain("and");
pageTier.Url.Query.Should().NotContain(" & ");
pageTier.Url.Query.Should().NotContain("%26");
}
}
}

View File

@ -470,7 +470,8 @@ namespace NzbDrone.Core.Indexers.Newznab
private static string NewsnabifyTitle(string title)
{
return title.Replace("+", "%20");
title = title.Replace("+", " ");
return Uri.EscapeDataString(title);
}