From 3f629ba7d2c2fa3d1759e7226711f0bee3dfca27 Mon Sep 17 00:00:00 2001 From: kaso17 Date: Tue, 6 Dec 2016 09:40:38 +0100 Subject: [PATCH] automatically decode CloudFlare protected emails --- src/Jackett/Utils/BrowserUtil.cs | 33 +++++++++++++++++++ src/Jackett/Utils/Clients/HttpWebClient.cs | 16 +++++++-- .../Utils/Clients/UnixLibCurlWebClient.cs | 17 ++++++++-- 3 files changed, 61 insertions(+), 5 deletions(-) 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>