Fix indexer class lookup by string when name has non-alphanumeric chars

This commit is contained in:
unknown
2015-07-19 11:37:08 -06:00
parent 644cf939ca
commit c2add69276
4 changed files with 24 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ using System.Threading.Tasks;
using System.Web;
using System.Web.UI.WebControls;
namespace Jackett
namespace Jackett.Indexers
{
public class Freshon : BaseIndexer, IIndexer
{

View File

@@ -197,6 +197,7 @@
<Compile Include="Models\TorznabQuery.cs" />
<Compile Include="CurlHelper.cs" />
<Compile Include="Indexers\AlphaRatio.cs" />
<Compile Include="Utils\StringUtil.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />

View File

@@ -1,6 +1,7 @@
using Autofac;
using Jackett.Indexers;
using Jackett.Models;
using Jackett.Utils;
using Newtonsoft.Json.Linq;
using NLog;
using System;
@@ -52,7 +53,7 @@ namespace Jackett.Services
public IIndexer GetIndexer(string name)
{
var indexer = indexers.Values.Where(i => string.Equals(i.DisplayName, name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
var indexer = indexers.Values.Where(i => string.Equals(StringUtil.StripNonAlphaNumeric(i.DisplayName), name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
if (indexer != null)
{
return indexer;

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Jackett.Utils
{
public static class StringUtil
{
public static string StripNonAlphaNumeric(string str)
{
Regex rgx = new Regex("[^a-zA-Z0-9 -]");
str = rgx.Replace(str, "");
return str;
}
}
}