From 06901c4aee727c0fdee6e1429c0c2c09d2fd4a4d Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 15 May 2021 18:31:08 -0400 Subject: [PATCH] Clean UA data --- src/NzbDrone.Core/Parser/UserAgentParser.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Parser/UserAgentParser.cs b/src/NzbDrone.Core/Parser/UserAgentParser.cs index 9c84b8be5..dd82df4f8 100644 --- a/src/NzbDrone.Core/Parser/UserAgentParser.cs +++ b/src/NzbDrone.Core/Parser/UserAgentParser.cs @@ -1,9 +1,12 @@ +using System.Collections.Generic; using System.Text.RegularExpressions; namespace NzbDrone.Core.Parser { public static class UserAgentParser { + private static readonly List UserAgentWhiteList = new List { "Radarr", "Sonarr", "Readarr", "Lidarr", "Prowlarr" }; + private static readonly Regex AppSourceRegex = new Regex(@"(?.*)\/.*(\(.*\))?", RegexOptions.IgnoreCase | RegexOptions.Compiled); public static string ParseSource(string userAgent) @@ -12,7 +15,10 @@ namespace NzbDrone.Core.Parser if (match.Groups["agent"].Success) { - return match.Groups["agent"].Value; + if (UserAgentWhiteList.Contains(match.Groups["agent"].Value)) + { + return match.Groups["agent"].Value; + } } return "Other";