private static void Parse(Page httpPage, Process process) { if (process.QueryEvents["xml"] == "true") { httpPage.Response.AddHeader("Content-Type", "text/xml"); httpPage.Response.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); httpPage.Response.Write(process.XmlData.OuterXml); } else { if (process.MainTemplate != null) { string output = CommonXml.TransformXsl(process.MainTemplate, process.XmlData, process.Cache); // ToDo: dirty hack string[] badtags = { "<ul />", "<li />", "<h1 />", "<h2 />", "<h3 />", "<div />", "<p />", "<font />", "<b />", "<strong />", "<i />" }; output = badtags.Aggregate(output, (current, a) => current.Replace(a, string.Empty)); Regex regex = new Regex("(?<email>(mailto:)([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3}))", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled); foreach (Match match in regex.Matches(output)) { output = output.Replace(match.Groups["email"].Value, HtmlObfuscate(match.Groups["email"].Value)); } httpPage.Response.Write(output); } } }
//private static void PrepareConfiguration(HttpApplicationState app, HttpServerUtility server) //{ // Cache cache = new Cache(app); // List<string> configurationPaths = new List<string>(); // configurationPaths.Add(server.MapPath("~/Custom/Components")); // configurationPaths.Add(server.MapPath("~/System/Components")); // string[] settingsPaths = new string[3]; // configurationPaths.CopyTo(settingsPaths); // settingsPaths[2] = server.MapPath("~/Custom/App_Data/CustomSettings.xml"); // Configuration.CombineSettings(settingsPaths, cache); // string[] processPaths = new string[3]; // configurationPaths.CopyTo(processPaths); // processPaths[2] = server.MapPath("~/Custom/App_Data/CustomProcess.xml"); // Configuration.CombineProcessTree(processPaths, cache); //} private static string Parse(Process process) { //string output = CommonXml.TransformXsl(process.mainTemplate, process.XmlData, process.Cache, firstRun); string output = CommonXml.TransformXsl(process); // todo: dirty hack string[] badtags = { "<ul />", "<li />", "<h1 />", "<h2 />", "<h3 />", "<div />", "<p />", "<font />", "<b />", "<strong />", "<i />" }; foreach (string a in badtags) { output.Replace(a, ""); } return(output); }