html-escape

What's the difference between Android's Html.escapeHtml and TextUtils.htmlEncode ? When should I use one or the other?

别来无恙 提交于 2019-12-10 12:44:58
问题 Android has two different ways to escape / encode HTML characters / entities in Strings: Html.escapeHtml(String), added in API 16 (Android 4.1). The docs say: Returns an HTML escaped representation of the given plain text. TextUtils.htmlEncode(String) For this one, the docs say: Html-encode the string. Reading the docs, they both seem to do pretty much the same thing, but, when testing them, I get some pretty mysterious (to me) output. Eg. With the input: <p>This is a quote ". This is a euro

why does _.escape modify / characters in Underscore.js?

 ̄綄美尐妖づ 提交于 2019-12-10 02:36:59
问题 I was looking through the Underscore.js api and I noticed that _.escape escapes & , < , > , " , ' , and / characters. What surprised me was escaping / . Is there a reason to escape / characters that I don't know about? 回答1: EDIT : Alright, apparently, it is recommended by OWASP as it "helps end a HTML entity". Escape the following characters with HTML entity encoding to prevent switching into any execution context, such as script, style, or event handlers. Using hex entities is recommended in

why does _.escape modify / characters in Underscore.js?

元气小坏坏 提交于 2019-12-05 01:18:12
I was looking through the Underscore.js api and I noticed that _.escape escapes & , < , > , " , ' , and / characters. What surprised me was escaping / . Is there a reason to escape / characters that I don't know about? EDIT : Alright, apparently, it is recommended by OWASP as it "helps end a HTML entity". Escape the following characters with HTML entity encoding to prevent switching into any execution context, such as script, style, or event handlers. Using hex entities is recommended in the spec. In addition to the 5 characters significant in XML (&, <, >, ", '), the forward slash is included

h:outputText not rendering HTML from XML response in spite of escape=“false”

情到浓时终转凉″ 提交于 2019-12-02 09:01:29
I have the following code: <h:outputText value="#{bean.shortDescription}" escape="false" /> The result is: <p><b>Location. </b> <br /> a The string from #{bean.shortDescription} is being taken from an XML response that is escaped: <p><b>Location. </b> <br /> a If I make the same output text as above, but instead of taking the response from the XML, I just put the escaped string that comes from the response, e.g.: <h:outputText value="<p><b>Location. </b> <br /> a" escape="false" /> Then the result is: Location. a How can I properly render the HTML tags I get from the XML? I do not want to

<p:selectOneButton> with images

南楼画角 提交于 2019-12-01 06:29:50
I'm using JSF with Primefaces, I want to use a buttonset of radiobutton with only images but I can't make it work. Here's the code: <p:selectOneButton value="#{LoginBean.user}" > <f:selectItem itemLabel="<img src="/myApp/faces/javax.faces.resource/myImg1.png?ln=img"/>" itemValue="1"/> <f:selectItem itemLabel="<img src="/myApp/faces/javax.faces.resource/myImg2.png?ln=img"/>" itemValue="2"/> </p:selectOneButton> I tried escaping characters with "escape", "escapeItem" and even "itemEscaped" attributes. I read about the last one in this other question . The solution in that question uses <h

<p:selectOneButton> with images

感情迁移 提交于 2019-12-01 04:55:24
问题 I'm using JSF with Primefaces, I want to use a buttonset of radiobutton with only images but I can't make it work. Here's the code: <p:selectOneButton value="#{LoginBean.user}" > <f:selectItem itemLabel="<img src="/myApp/faces/javax.faces.resource/myImg1.png?ln=img"/>" itemValue="1"/> <f:selectItem itemLabel="<img src="/myApp/faces/javax.faces.resource/myImg2.png?ln=img"/>" itemValue="2"/> </p:selectOneButton> I tried escaping characters with "escape", "escapeItem" and even "itemEscaped"

How can I make a QString html-escaped

不打扰是莪最后的温柔 提交于 2019-11-30 17:03:28
How do I escape/sanitize a QString that contains HTML? I.e. showInBroswser(escaped(str)) == showInNotepad(str); PenguinCoder Qt 5 Use QString::toHtmlEscaped() QString src; Qstring html = src.toHtmlEscaped(); showInBrowser(html) == showInNotepad(str); Reference: http://doc.qt.io/qt-5/qstring.html#toHtmlEscaped Qt 4 Use Qt::escape . #include <QtGui/qtextdocument.h> QString src; Qstring html = Qt::escape(src); showInBrowser(html) == showInNotepad(str); Reference: http://doc.qt.io/qt-4.8/qt.html#escape gremwell Just to bring this answer up with the times, Qt 5.1 has QString::toHtmlEscaped() . If

<h:outputtext> prints HTML as-is instead of actual HTML [duplicate]

a 夏天 提交于 2019-11-30 08:19:50
This question already has an answer here: Component to inject and interpret String with HTML code into JSF page 1 answer I am using JSF 1.2 I am trying to print text using <h:outputtext> <h:outputText id="warningDose" styleClass="redText" value="#{templatePrescriptionMaintenanceBackingBean.doseWarningText}"></h:outputText> Now this variable contains text with html tags. <b> , <i> etc... But that displays content as it is instead of actual bold or italic html output. Is there any way we can make this <h:outputText> such that it gives html response? You should set in the h:outputText tag: escape

How can I make a QString html-escaped

只愿长相守 提交于 2019-11-30 00:16:26
问题 How do I escape/sanitize a QString that contains HTML? I.e. showInBroswser(escaped(str)) == showInNotepad(str); 回答1: Qt 5 Use QString::toHtmlEscaped() QString src; Qstring html = src.toHtmlEscaped(); showInBrowser(html) == showInNotepad(str); Reference: http://doc.qt.io/qt-5/qstring.html#toHtmlEscaped Qt 4 Use Qt::escape . #include <QtGui/qtextdocument.h> QString src; Qstring html = Qt::escape(src); showInBrowser(html) == showInNotepad(str); Reference: http://doc.qt.io/qt-4.8/qt.html#escape

h:outputText not rendering HTML from XML response in spite of escape=“false”

十年热恋 提交于 2019-11-28 11:49:25
I have the following code: <h:outputText value="#{bean.shortDescription}" escape="false" /> The result is: <p><b>Location. </b> <br /> a The string from #{bean.shortDescription} is being taken from an XML response that is escaped: <p><b>Location. </b> <br /> a If I make the same output text as above, but instead of taking the response from the XML, I just put the escaped string that comes from the response, e.g.: <h:outputText value="<p><b>Location. </b> <br /> a" escape="false" /> Then the result is: Location. a How can I properly render the HTML tags I get from the XML? I do not want to