diff --git a/src/Jackett.Common/Indexers/Definitions/MyAnonamouse.cs b/src/Jackett.Common/Indexers/Definitions/MyAnonamouse.cs index 4cae9cd33..aff39998f 100644 --- a/src/Jackett.Common/Indexers/Definitions/MyAnonamouse.cs +++ b/src/Jackett.Common/Indexers/Definitions/MyAnonamouse.cs @@ -4,6 +4,7 @@ using System.Collections.Specialized; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Jackett.Common.Extensions; using Jackett.Common.Models; @@ -33,6 +34,8 @@ namespace Jackett.Common.Indexers.Definitions private string SearchUrl => SiteLink + "tor/js/loadSearchJSONbasic.php"; + private static readonly Regex _SanitizeSearchQueryRegex = new Regex("[^\\w]+", RegexOptions.IgnoreCase | RegexOptions.Compiled); + private new ConfigurationDataMyAnonamouse configData => (ConfigurationDataMyAnonamouse)base.configData; public MyAnonamouse(IIndexerConfigurationService configService, WebClient c, Logger l, IProtectionService ps, @@ -181,12 +184,23 @@ namespace Jackett.Common.Indexers.Definitions protected override async Task> PerformQuery(TorznabQuery query) { + var releases = new List(); + + var term = _SanitizeSearchQueryRegex.Replace(query.GetQueryString(), " ").Trim(); + + if (query.SearchTerm.IsNotNullOrWhiteSpace() && term.IsNullOrWhiteSpace()) + { + logger.Debug("Search term is empty after being sanitized, stopping search. Initial search term: '{0}'", query.SearchTerm); + + return releases; + } + var limit = query.Limit > 0 ? query.Limit : 100; var offset = query.Offset > 0 ? query.Offset : 0; var qParams = new NameValueCollection { - {"tor[text]", query.GetQueryString()}, + {"tor[text]", term}, {"tor[searchType]", configData.SearchType.Value}, {"tor[srchIn][title]", "true"}, {"tor[srchIn][author]", "true"}, @@ -247,8 +261,6 @@ namespace Jackett.Common.Indexers.Definitions throw new Exception(response.ContentString); } - var releases = new List(); - try { var jsonContent = JObject.Parse(response.ContentString);