html-encode

html_entity_decode problem in PHP?

泪湿孤枕 提交于 2019-11-30 04:51:10
I am trying to convert HTML entities from a source string to their literal character equivalent. For example: <?php $string = "Hello – World"; $converted = html_entity_decode($string); ?> Whilst this rightly converts the entity on screen, when I look at the HTML code it is still showing the explicit entity. I need to change that so that it literally converts the entity as I am not using the string within an HTML page. Any ideas on what I am doing wrong? FYI I am sending the converted string to Apple's Push notification service: $payload['aps'] = array('alert' => $converted, 'badge' => 1,

Converting & to & etc

痴心易碎 提交于 2019-11-30 04:37:27
I want to convert & to &, " to " etc. Is there a function in c# that could do that without writing all the options manually? System.Web.HttpUtility.HtmlDecode() Edit : Note from here that "To encode or decode values outside of a web application, use..." System.Net.WebUtility.HtmlDecode() Use the static method HttpUtility.HtmlEncode to change & to & and " to " . Use HttpUtility.HtmlDecode to do the reverse. Corredera Romain You can use System.Net.WebUtility.HtmlDecode(uri); Server.HtmlDecode . A good article about this subject : Different ways how to escape an XML string in C# Alex W. using

C# HTMLDecode without System.Web possible?

白昼怎懂夜的黑 提交于 2019-11-30 01:44:29
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? Developers who need to use System.Web.HttpUtility in their client apps and had to reference System.Web.dll and therefore target NET4 full (System.Web.dll is in Full) , can now target the NET4 Client Profile by using the new System.Net

How do I output raw html when using RazorEngine (NOT from MVC)

天涯浪子 提交于 2019-11-29 23:25:26
I am trying to generate emails with HTML content. this content has already gone through sanitation so I am not worried in that regard, however when I call: Razor.Parse(template, model); on the following Razor template: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <body> @(new System.Web.HtmlString(Model.EmailContent)) </body> </html> the email that is outputted is HTMl encoded, but I need it decoded. How can I accomplish this? RazorEngine, like MVC's Razor View Engine, will automatically encode values written to the template. To get around this, we've introduce an

How do I display html encoded values in svg?

十年热恋 提交于 2019-11-29 15:29:39
I am using d3 to generate svg and end up with markup similar to the following: <text class="rule" text-anchor="middle">&pound;10K</text> Compare to similar html that renders as expected. <div> £20,160 - £48,069 </div> Is there a property I need to set on the svg tag to get a similar type of encoding? I tried adding a meta tag to the page <meta name="content" content="application/xhtml+xml; charset=utf-8" /> but this did not work. HTML entities are not defined in SVG. You can either use the actual unicode character or use the foreignObject element to embed HTML into your SVG. Since you are

Correct PHP method to store special chars in MySQL DB

十年热恋 提交于 2019-11-29 14:16:37
Using PHP, what is the best way to store special characters (like the following) in a MSQUL database, to avoid injections. « " ' é à ù This is how I do it now: $book_text=$_POST['book_text']; $book_text=htmlentities($book_text, "ENT_QUOTES"); $query=//DB query to insert the text Then: $query=//DB query to select the text $fetch=//The fetch of $book_text $book_text=html_entity_decode($book_text); This way, all my text is formatted in HTML entities. But I think this takes up a lot of database space. So, is there a better way? Use utf8 encoding to store these values. To avoid injections use mysql

A potentially dangerous Request.Form value was detected from the client

雨燕双飞 提交于 2019-11-29 13:47:51
I'm getting the above exception when I'm trying to submit a form in ASP.NET. This post was really helpful but even after setting ValidateRequest="false" I get this error only for "&#" combination. This specific combination is required since we are using Norwegian characters. And I have set httpRuntime requestValidationMode="2.0" in web.config as well. Ok, from the comments, I make it also as an answer. Place the ValidateRequest="false" on the web.config to prevent the case that its hit on a forgotten page with out this declaration. <pages validateRequest="false" ... > 来源: https://stackoverflow

How does Html.Raw MVC helper work?

那年仲夏 提交于 2019-11-29 13:31:55
I use the Html.Raw to print a raw html content, for example when I send some thing like ViewBag.div = "<div> Hello </div>"; from the controller to the view side it does not print a raw html content unless I use the Html.Raw method but if I have an encoded content, like content encoded using jquery and inserted into the database and I want to print it as a raw html content the Html.Raw method does not work and I have to use HttpUtility.HtmlDecode(EncodedContent) before I use Html.Raw so please could anyone explain why it acts in this way and what is the proper situation to use Html.Raw method?

Render or convert Html to 'formatted' Text (.NET)

喜夏-厌秋 提交于 2019-11-29 12:51:09
问题 I'm importing some data from another test/bug tracking tool into tfs, and I would like to convert it's description, which is in simple HTML, so a plain string, where the 'layout' of the HTML is preserved. For example: <body> <ol> <li>Log on with user Acme & Co.</li> <li>Navigate to the details tab</li> <li>Check the official name</li> </ol> <br> <br> Expected Result:<br> official name is filled in<br> <br> Actual Result:<br> The &-sign is not shown correctly<br> See attachement. </body> Would

how to encode href attribute in HTML

不羁的心 提交于 2019-11-29 05:51:14
What should be done against contents of href attribute: HTML or URL encoding? <a href="???">link text</a> On the one hand, since href attribute contains URL I should use URL encoding. On the other hand, I'm inserting this URL into HTML, so it must be HTML encoded. Please help me to overcome this contradiction. Thanks. EDIT: Here's the contradiction. Suppose there might be the '<' and '>' characters in the URL. URL encoding won't escape them, so there will be reserved HTML characters inside the href attribute, which violates the standard. HTML encoding will escape '<' and '>' characters and