mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Clean UA data
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Parser
|
namespace NzbDrone.Core.Parser
|
||||||
{
|
{
|
||||||
public static class UserAgentParser
|
public static class UserAgentParser
|
||||||
{
|
{
|
||||||
|
private static readonly List<string> UserAgentWhiteList = new List<string> { "Radarr", "Sonarr", "Readarr", "Lidarr", "Prowlarr" };
|
||||||
|
|
||||||
private static readonly Regex AppSourceRegex = new Regex(@"(?<agent>.*)\/.*(\(.*\))?",
|
private static readonly Regex AppSourceRegex = new Regex(@"(?<agent>.*)\/.*(\(.*\))?",
|
||||||
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
public static string ParseSource(string userAgent)
|
public static string ParseSource(string userAgent)
|
||||||
@@ -11,9 +14,12 @@ namespace NzbDrone.Core.Parser
|
|||||||
var match = AppSourceRegex.Match(userAgent);
|
var match = AppSourceRegex.Match(userAgent);
|
||||||
|
|
||||||
if (match.Groups["agent"].Success)
|
if (match.Groups["agent"].Success)
|
||||||
|
{
|
||||||
|
if (UserAgentWhiteList.Contains(match.Groups["agent"].Value))
|
||||||
{
|
{
|
||||||
return match.Groups["agent"].Value;
|
return match.Groups["agent"].Value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return "Other";
|
return "Other";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user