public static HtmlNode FilePage(SoftFile i) { HtmlNode node = HtmlNode.CreateNode("<div id=\"filepage\" />"); var head = node.AppendChild(HtmlNode.CreateNode("<div id=\"fileheader\" />")); head.AppendChild(HtmlNode.CreateNode($"<h1 id=\"filetitle\">{Encode.HtmlEncode(i.Name)}</h1>")); if (i.ThumbnailExists) { head.AppendChild(Thumbnail(i, i.Id.ToString())); } //node.AppendChild(Thumbnail(i, i.Id.ToString())); var tagsandref = node.AppendChild(HtmlNode.CreateNode("<div id=\"tagsandref\" />")); var refrr = i.References; if (refrr.Count > 0) { tagsandref.AppendChild(List("div", "References", "filereferencelist", refrr.Select(n => $"<a id=\"filereferences\" href=\"/file&{n.Id}\">{Encode.HtmlEncode(n.Name)}</a>").ToArray())); } node.AppendChild(HtmlNode.CreateNode($"<p id=\"hashes\">{i.Hashes}</p>")); var tags = i.Tags; if (tags.Count > 0) { tagsandref.AppendChild(List("div", "Tags", "taglist", tags.Select(n => $"<p id=\"tag\">{n}</p>").ToArray())); } return(node); }
/// <summary> /// Renders a summary about the <see cref="Error"/> object in /// body of the HTML document. /// </summary> protected virtual void RenderSummary() { HtmlTextWriter writer = this.Writer; Error error = this.Error; // // Write the error type and message. // writer.AddAttribute(HtmlTextWriterAttribute.Id, "errorMessage"); writer.RenderBeginTag(HtmlTextWriterTag.P); HttpUtility.HtmlEncode(error.Type, writer); writer.Write(": "); HttpUtility.HtmlEncode(error.Message, writer); writer.RenderEndTag(); // </p> writer.WriteLine(); // // Write out the time, in UTC, at which the error was generated. // if (error.Time != DateTime.MinValue) { writer.RenderBeginTag(HtmlTextWriterTag.P); writer.Write("Generated: "); HttpUtility.HtmlEncode(error.Time.ToUniversalTime().ToString("r"), writer); writer.RenderEndTag(); // </p> writer.WriteLine(); } }
public static HtmlNode IndexPage(CentralIndex i) { HtmlNode node = HtmlNode.CreateNode("<div id=\"indexpage\" />"); node.AppendChild(HtmlNode.CreateNode($"<h1 id=\"indextitle\">{Encode.HtmlEncode("Index of /")}</h1>")); foreach (var a in i.Files) { node.AppendChild(FileStrip(a)); } return(node); }
public static HtmlNode IndexPage(SoftDirectory i) { HtmlNode node = HtmlNode.CreateNode("<div id=\"indexpage\" />"); node.AppendChild(HtmlNode.CreateNode($"<h1 id=\"indextitle\">{Encode.HtmlEncode($"Index of {i}")}</h1>")); foreach (var a in i.SoftFiles) { node.AppendChild(FileStrip(a)); } return(node); }
/// <summary> /// Renders the contents of the control into the specified writer. /// </summary> protected override void RenderContents(HtmlTextWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } // // Write out the assembly title, version number, copyright and // license. // AboutSet about = this.About; writer.Write("Powered by "); writer.AddAttribute(HtmlTextWriterAttribute.Href, "http://elmah.googlecode.com/"); writer.RenderBeginTag(HtmlTextWriterTag.A); HttpUtility.HtmlEncode(Mask.EmptyString(about.Product, "(product)"), writer); writer.RenderEndTag(); writer.Write(", version "); string version = about.GetFileVersionString(); if (version.Length == 0) { version = about.GetVersionString(); } HttpUtility.HtmlEncode(Mask.EmptyString(version, "?.?.?.?"), writer); #if DEBUG writer.Write(" (" + Build.Configuration + ")"); #endif writer.Write(". "); string copyright = about.Copyright; if (copyright.Length > 0) { HttpUtility.HtmlEncode(copyright, writer); writer.Write(' '); } writer.Write("Licensed under "); writer.AddAttribute(HtmlTextWriterAttribute.Href, "http://www.apache.org/licenses/LICENSE-2.0"); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write("Apache License, Version 2.0"); writer.RenderEndTag(); writer.Write(". "); }
/// <summary> /// Renders the details about the <see cref="Error" /> object in /// body of the HTML document. /// </summary> protected virtual void RenderDetail() { HtmlTextWriter writer = this.Writer; // // Write the full text of the error. // writer.AddAttribute(HtmlTextWriterAttribute.Id, "errorDetail"); writer.RenderBeginTag(HtmlTextWriterTag.Pre); writer.InnerWriter.Flush(); HttpUtility.HtmlEncode(this.Error.Detail, writer.InnerWriter); writer.RenderEndTag(); // </pre> writer.WriteLine(); }
/// <summary> /// Adds parameters to template <paramref name="links"/>. /// </summary> /// <param name="links">Template links.</param> private static Dictionary <string, string> ModifyTemplateLinks(IEnumerable <string> links) { var results = new Dictionary <string, string>(); foreach (string link in links) { string modifiedLink = link; string linkHref = MailingUtilities.ParseHtmlHrefValue(modifiedLink); if (!string.IsNullOrEmpty(linkHref)) { string decodedLinkHref = HttpUtility.HtmlDecode(HttpUtility.UrlDecode(linkHref)); string modifiedLinkHref = AddParametersToLink(decodedLinkHref); modifiedLink = link.ReplaceFirstInstanceOf(linkHref, HttpUtility.HtmlEncode(modifiedLinkHref)); } results[link] = modifiedLink; } return(results); }
/// <summary> /// Renders the contents of the control into the specified writer. /// </summary> protected override void RenderContents(HtmlTextWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } // // Write out the assembly title, version number and copyright. // writer.Write("Powered by "); HttpUtility.HtmlEncode(this.VersionInfo.ProductName, writer); writer.Write(", version "); HttpUtility.HtmlEncode(this.VersionInfo.FileVersion, writer); writer.Write(". "); HttpUtility.HtmlEncode(this.VersionInfo.LegalCopyright, writer); writer.Write(' '); }
/// <summary> /// Renders the <head> section of the HTML document. /// </summary> protected virtual void RenderHead() { HtmlTextWriter writer = this.Writer; writer.RenderBeginTag(HtmlTextWriterTag.Head); // // Write the document title and style. // writer.RenderBeginTag(HtmlTextWriterTag.Title); writer.Write("Error: "); HttpUtility.HtmlEncode(this.Error.Message, writer); writer.RenderEndTag(); // </title> writer.WriteLine(); RenderStyle(); writer.RenderEndTag(); // </head> writer.WriteLine(); }
private void EmailButton_OnClick(object sender, RoutedEventArgs e) { // Try getting the Windows 10 "build", e.g. 1909 var releaseId = "???"; try { releaseId = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId", "").ToString(); } catch { // ignored } var os = HttpUtility.HtmlEncode($"{Environment.OSVersion} - {releaseId} ({Environment.Version})"); var lang = HttpUtility.HtmlEncode(App.Settings.LauncherLanguage.GetValueOrDefault(LauncherLanguage.English) .ToString()); var wine = EnvironmentSettings.IsWine ? "Yes" : "No"; Process.Start(string.Format( "mailto:[email protected]?subject=XIVLauncher%20Feedback&body=This%20is%20my%20XIVLauncher%20Feedback.%0A%0AMy%20OS%3A%0D{0}%0ALauncher%20Language%3A%0D{1}%0ARunning%20on%20Wine%3A%0D{2}", os, lang, wine)); }
private static HtmlNode Text(string text, string tag, string id) { return(HtmlNode.CreateNode($"<{tag} id=\"{id}\">{Encode.HtmlEncode(text)}</{tag}>")); }
private static HtmlNode Text(string text, string tag) { return(HtmlNode.CreateNode($"<{tag}>{Encode.HtmlEncode(text)}</{tag}>")); }
public void HtmlEncode_1() { Console.WriteLine(SymbolChars); Console.WriteLine(NetWebUtility.HtmlEncode(SymbolChars)); Console.WriteLine(WebHttpUtility.HtmlEncode(SymbolChars)); }
public static HtmlNode List(string tag, string title, string id, params string[] vs) { HtmlNode node = HtmlNode.CreateNode($"<{tag} id=\"{id}\" />"); node.AppendChild(HtmlNode.CreateNode("<div id=\"listtitle\" />")).AppendChild(HtmlNode.CreateNode($"<h1>{Encode.HtmlEncode(title)}</h1>")); var div = node.AppendChild(HtmlNode.CreateNode("<div id=\"list\" />")); foreach (var a in vs) { div.AppendChild(HtmlNode.CreateNode(a)); } return(node); }
/// <summary> /// Renders the contents of the control into the specified writer /// </summary> protected override void RenderContents(HtmlTextWriter w) { HttpUtility.HtmlEncode(this.VersionInfo.ProductName, w); w.Write(" "); HttpUtility.HtmlEncode(this.VersionInfo.FileVersion, w); }
/// <summary> /// Renders a collection as a table in HTML document body. /// </summary> /// <remarks> /// This method is called by <see cref="RenderCollections"/> to /// format a diagnostic collection from <see cref="Error"/> object. /// </remarks> protected virtual void RenderCollection(NameValueCollection collection, string caption) { if (collection == null || collection.Count == 0) { return; } HtmlTextWriter writer = this.Writer; writer.RenderBeginTag(HtmlTextWriterTag.H1); HttpUtility.HtmlEncode(caption, writer); writer.RenderEndTag(); // </h1> writer.WriteLine(); // // Write a table with each key in the left column // and its value in the right column. // writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "5"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "1"); writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); writer.RenderBeginTag(HtmlTextWriterTag.Table); // // Write the column headings. // writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top"); writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddAttribute(HtmlTextWriterAttribute.Align, "left"); writer.RenderBeginTag(HtmlTextWriterTag.Th); writer.Write("Name"); writer.RenderEndTag(); // </th> writer.AddAttribute(HtmlTextWriterAttribute.Align, "left"); writer.RenderBeginTag(HtmlTextWriterTag.Th); writer.Write("Value"); writer.RenderEndTag(); // </th> writer.RenderEndTag(); // </tr> // // Write the main body of the table containing keys // and values in a two-column layout. // foreach (string key in collection.Keys) { writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top"); writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.RenderBeginTag(HtmlTextWriterTag.Td); HttpUtility.HtmlEncode(key, writer); writer.RenderEndTag(); // </td> writer.RenderBeginTag(HtmlTextWriterTag.Td); string value = StringEtc.MaskNull(collection[key]); if (value.Length != 0) { HttpUtility.HtmlEncode(value, writer); } else { writer.Write(" "); } writer.RenderEndTag(); // </td> writer.RenderEndTag(); // </tr> } writer.RenderEndTag(); // </table> writer.WriteLine(); }
/// <summary> /// Converts a text string into an HTML-encoded string. /// </summary> /// <param name="html">The text to HTML-encode.</param> /// <returns>An HTML-encoded string.</returns> public static string HtmlEncode(string html) { return(HttpUtilityStd.HtmlEncode(html)); }