Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static class FilterBypaser
- {
- private static bool hasInitialized = false;
- private static void Initialize()
- {
- if (hasInitialized)
- return;
- else
- hasInitialized = true;
- exclusionList = new char[] { '.', '/' };
- bool excluded = false;
- for (uint i = 0x20; i < 255; i++, excluded = false)
- {
- for (int j = 0; j < exclusionList.Length && !excluded; j++)
- excluded = exclusionList[j] == (char)i;
- if (excluded)
- continue;
- replacments.Add(new Replacments()
- {
- Character = ((char)((byte)i)),
- CharacterReplacment = string.Format("%{0}", i.ToString("X")),
- });
- }
- }
- private static char[] exclusionList;
- private static List<Replacments> replacments = new List<Replacments>();
- private struct Replacments
- {
- public char Character;
- public string CharacterReplacment;
- }
- public static string GetBbCodeFilter(string url)
- {
- Initialize();
- string encodedUrl = null;
- bool foundReplacment = false;
- bool isSsl = url.StartsWith("https://");
- url = url.Replace(isSsl ? "https://" : "http://", "");
- for (int i = 0; i < url.Length; i++, foundReplacment = false)
- {
- for (int j = 0; j < replacments.Count && !foundReplacment; j++)
- if ((foundReplacment = (url[i] == replacments[j].Character)))
- encodedUrl = string.Format("{0}{1}", encodedUrl, replacments[j].CharacterReplacment);
- if (!foundReplacment)
- encodedUrl += url[i];
- }
- return string.Format("[url=\"{0}{1}\"]Enter click here text[/url]", isSsl ? "https://" : "http://", encodedUrl);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement