html-encode

Where is HtmlEncode in Asp.NET 5

假如想象 提交于 2020-01-01 08:47:08
问题 I have a custom IHtmlHelper extension method that uses TagBuilder and returns an HtmlString . I can no longer pass tagBuiler.ToString() to the HtmlString constructor as that just returns the typename now. I see I can use the tabBuiler.WriteTo(TextWriter, IHtmlEncoder) method but I don't know exactly how to get my hands on an object that implments IHtmlEncoder . I see encoders in both System.Text.Encodings.Web and Microsoft.Framework.WebEncoders . But the types in the two namespace don't seem

Does C# have something like PHP's mb_convert_encoding()?

非 Y 不嫁゛ 提交于 2019-12-30 11:55:22
问题 Is there a way on C# that I can convert unicode strings into ASCII + html entities, and then back again? See, in PHP, I can do it like so: <?php // RUN ME AT COMMAND LINE $sUnicode = '<b>Jöhan Strauß</b>'; echo "UNICODE: $sUnicode\n"; $sASCII = mb_convert_encoding($sUnicode, 'HTML-ENTITIES','UTF-8'); echo "ASCII: $sASCII\n"; $sUnicode = mb_convert_encoding($sASCII, 'UTF-8', 'HTML-ENTITIES'); echo "UNICODE (TRANSLATED BACK): $sUnicode\n"; Background: I need this to work in C# .NET 2 because we

C# HTMLDecode without System.Web possible?

故事扮演 提交于 2019-12-29 19:04:48
问题 I know there are different methods in the System.Web namespace for decoding html entities (such as "%20" for space). I'm building a Winforms application however, but needs to deal with html encoded strings. Basically I have the iTunes Library XML file and need to decode the URLs in there to check the files. Is this possible without the System.Web namespace? 回答1: Developers who need to use System.Web.HttpUtility in their client apps and had to reference System.Web.dll and therefore target NET4

C# HTMLDecode without System.Web possible?

帅比萌擦擦* 提交于 2019-12-29 19:04:07
问题 I know there are different methods in the System.Web namespace for decoding html entities (such as "%20" for space). I'm building a Winforms application however, but needs to deal with html encoded strings. Basically I have the iTunes Library XML file and need to decode the URLs in there to check the files. Is this possible without the System.Web namespace? 回答1: Developers who need to use System.Web.HttpUtility in their client apps and had to reference System.Web.dll and therefore target NET4

How To Replace < with < and > with > using jquery

我只是一个虾纸丫 提交于 2019-12-29 03:30:08
问题 I have a page that is part of a backend CRM admin panel. On that page the HTML output comes from some PHP functions that I can't access. And that HTML automatically changes < and > into HTML encoded characters. So there is a div that contains html tags like <br /> that is converted into <b /> So I need to change it back to the HTML characters using only jQuery: < to < > to > Is there a jQuery script I can use to replace those special characters with the corresponding symbols? This will mean

How to HTML-encode in the JSP expression language?

左心房为你撑大大i 提交于 2019-12-28 16:44:33
问题 Consider the following piece of JSP: <param name="FlashVars" value="${flashVars}" /> The value of ${flashVars} contains ampersands and needs to be encoded before it is output. Instead, JSP expects the value of ${flashVars} to be a piece of HTML and outputs the ampersands verbatim, resulting in bad HTML. I found out that I can get the value to be encoded if I write it like this: <param name="FlashVars" value="<c:out value="${flashVars}"/>" /> But this looks really ugly and confuses my IDE to

Which characters need to be escaped in HTML?

烈酒焚心 提交于 2019-12-27 10:36:05
问题 Are they the same as XML, perhaps plus the space one (   )? I've found some huge lists of HTML escape characters but I don't think they must be escaped. I want to know what needs to be escaped. 回答1: If you're inserting text content in your document in a location where text content is expected 1 , you typically only need to escape the same characters as you would in XML. Inside of an element, this just includes the entity escape ampersand & and the element delimiter less-than and greater-than

Which characters need to be escaped in HTML?

泄露秘密 提交于 2019-12-27 10:35:06
问题 Are they the same as XML, perhaps plus the space one (   )? I've found some huge lists of HTML escape characters but I don't think they must be escaped. I want to know what needs to be escaped. 回答1: If you're inserting text content in your document in a location where text content is expected 1 , you typically only need to escape the same characters as you would in XML. Inside of an element, this just includes the entity escape ampersand & and the element delimiter less-than and greater-than

Is it safe to render Html that was uploaded as Markdown and converted serverside to Html?

三世轮回 提交于 2019-12-24 06:58:52
问题 I have a webform that allows users to upload text as Markdown. The Markdown is converted to Html on the server(using Markdig) and also stored. When displaying the converted Html that the user uploaded, should I @Html.Encode the content - the project is in c#, MVC 5/razor with request validation on. 回答1: No, it isn't. I just trivially tested the following: <a href="javascript:evil()">hello</a> and markdig lets it through: See online example. Although I haven't looked into it too deeply, the

MVC3 C# Potentially dangerous request error

允我心安 提交于 2019-12-24 00:03:55
问题 I have an MVC3 C#. Web App. One of our properties uses an RTF control for our TextBoxFor controls: @Html.TextAreaFor(model => model.SowDescription, (object)new { rows = 7, cols = 65, @class = "celltext2 save-alert attachmentEditor", disabled = "disabled" } THe attachmentEditor class uses CkEditor. So there are html tags embedded in the control for Bold, Italics, etc. A user pasted some data into this TextArea and we received this error: A potentially dangerous Request.Form value was detected