diff --git a/src/Jackett/Utils/BrowserUtil.cs b/src/Jackett/Utils/BrowserUtil.cs index 06d5e5e95..9d1fd1e66 100644 --- a/src/Jackett/Utils/BrowserUtil.cs +++ b/src/Jackett/Utils/BrowserUtil.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace Jackett.Utils @@ -21,5 +22,37 @@ namespace Jackett.Utils } } } + + // This can be used to decode e-mail addresses protected by cloudflare + public static string DecodeCloudFlareProtectedEmail(string input) + { + var key = Convert.ToInt32(input.Substring(0, 2), 16); + string result = ""; + for (var i = 2; i < input.Length - 1; i += 2) + { + var hexChar = input.Substring(i, 2); + var intChar = Convert.ToInt32(hexChar, 16) ^ key; + var strChar = Convert.ToChar(intChar); + result += strChar; + } + return result; + } + + // decode cloudflare protected emails in a HTML document + public static string DecodeCloudFlareProtectedEmailFromHTML(string html) + { + Regex CFEMailRegex = new Regex("\\[email protected\\]<\\/span>