html-encode

Return raw string from REST service method

一曲冷凌霜 提交于 2019-12-01 03:24:17
I have a REST service method written in C#, defined as below: [WebGet(UriTemplate = "/{par1}/{par2}/{par3}")] public string ProcessGet(string par1, string par2, string par3) { return Execute(...); } It should return result as XML or JSON, based on one parameter (I generate the json and XML serialization) How can I make this method to return the RAW string, just as I created it, without HTMLEncoding it? Thank you Return it as a Stream - that causes the "raw" mode to be used and WCF will not touch your response. You can find more information at http://blogs.msdn.com/b/carlosfigueira/archive/2008

Turn off HTML Encoding in Razor

时光怂恿深爱的人放手 提交于 2019-12-01 02:11:36
I have a function that returns a snippet of JavaScript and/or HTML. static public string SpeakEvil() { return "<script>alert('BLAH!!');</script>"; } In the view, Razor is quite rightly HTML encoding it, as most would expect. @StaticFunctions.SpeakEvil() How do I have Razor not HTML Encode this, so that the HTML and JavaScript are emitted verbatim, and that any script actually runs? You could use the Raw() function but it's mostly meant for things that come from the database. For a helper like you have I would suggest returning an IHtmlString : static public IHtmlString SpeakEvil() { return new

Return raw string from REST service method

僤鯓⒐⒋嵵緔 提交于 2019-11-30 23:47:36
问题 I have a REST service method written in C#, defined as below: [WebGet(UriTemplate = "/{par1}/{par2}/{par3}")] public string ProcessGet(string par1, string par2, string par3) { return Execute(...); } It should return result as XML or JSON, based on one parameter (I generate the json and XML serialization) How can I make this method to return the RAW string, just as I created it, without HTMLEncoding it? Thank you 回答1: Return it as a Stream - that causes the "raw" mode to be used and WCF will

Turn off HTML Encoding in Razor

╄→尐↘猪︶ㄣ 提交于 2019-11-30 22:29:50
问题 I have a function that returns a snippet of JavaScript and/or HTML. static public string SpeakEvil() { return "<script>alert('BLAH!!');</script>"; } In the view, Razor is quite rightly HTML encoding it, as most would expect. @StaticFunctions.SpeakEvil() How do I have Razor not HTML Encode this, so that the HTML and JavaScript are emitted verbatim, and that any script actually runs? 回答1: You could use the Raw() function but it's mostly meant for things that come from the database. For a helper

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

可紊 提交于 2019-11-30 11:11:57
问题 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? 回答1: RazorEngine, like MVC's Razor View

Correct PHP method to store special chars in MySQL DB

江枫思渺然 提交于 2019-11-30 09:14:51
问题 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

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

☆樱花仙子☆ 提交于 2019-11-30 09:02:26
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 become plain text with newlines inserted and HTML-entities translated like: 1. Log on with user Acme &

Should HTML be encoded before being persisted?

房东的猫 提交于 2019-11-30 08:33:09
Should HTML be encoded before being stored in say, a database? Or is it normal practice to encode on its way out to the browser? Should all my text based field lengths be quadrupled in the database to allow for extra storage? Looking for best practice rather than a solid yes or no :-) Is the data in your database really HTML or is it application data like a name or a comment that you just happen to know will end up as part of an HTML page? If it's application data, I think its best to: represent it in a form that native to the environment (e.g. unencoded in the database), and make sure its

how to encode href attribute in HTML

荒凉一梦 提交于 2019-11-30 07:59:16
问题 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

Arabic language in php/mysql appears “????” question marks in html [duplicate]

*爱你&永不变心* 提交于 2019-11-30 06:36:58
Possible Duplicate: Save Data in Arabic in MySQL database I have a problem with retrieving Arabic data from MYSQL database using PHP, it appears as question marks "????" in HTML: I have a database with "utf8_general_ci" as collation. The database contains some data in Arabic Language. The HTML encoding is "UTF-8". When I tried to retrieve the data in HTML, it appears as "?????". Please Help !!! you must set charset in first connect with mysql by this query: SET CHARACTER SET utf8 for example in mysqli functions $MySQL_Handle = mysqli_connect(HOSTNAME,DATABASE_USERNAME,DATABASE_PASSWORD