escaping

How do I textile and sanitize html?

只谈情不闲聊 提交于 2019-11-29 07:30:52
Now i ran into some stupid situation. I want the users to be able to use textile, but they shouldn't mess around with my valid HTML around their entry. So I have to escape the HTML somehow. html_escape(textilize("</body>Foo")) would break textile while textilize(html_escape("</body>Foo")) would work, but breaks various Textile features like links (written like "Linkname":http://www.wheretogo.com/ ), since the quotes would be transformed into " and thus not detected by textile anymore. sanitize doesn't do a better job. Any suggestions on that one? I would prefer not to use Tidy for this problem

How can I escape unicode characters in a NSString?

孤人 提交于 2019-11-29 07:22:39
When I store a NSString inside some NSDictionary and log that dictionary to the console like this: NSString *someString = @"Münster"; NSDictionary *someDict = [ NSDictionary dictionaryWithObjectsAndKeys: someString, @"thestring" ]; NSLog ( @"someDict: %@", [ someDict description ] ); The console output looks like this: unicode_test[3621:903] someDict: { thestring = "M\U00fcnster"; } with the string's unicode character escaped. Is there any method to convert a NSString to this escaped representation? The problem could be solved using a loop on a UniChar-string representation of the given string

How to escape '$' and '#' in Facelets/EL?

假如想象 提交于 2019-11-29 07:21:19
I'm using Java Facelets and jQuery, however the expression $('...') in jQuery conflicts with EL expression, how do I escape the jQuery's one? I'd like to escape a large chunk of Javascript, too. ANSWERED To convert the existing JSP to Facelets xhtml, it's convenient to just wrap the existing javascript by <![CDATA[ ... ]]> . However, the output scripts for <script> are wrapped by <!-- --> comment, which conflicts with CDATA section: <script><![CDATA[ scripts... ]]></script> => <script><!-- <![CDATA[ scripts... ]]> --></script> To resolve this problem, you should also comment out the CDATA:

Append HTML-escaped text: jQuery

瘦欲@ 提交于 2019-11-29 07:15:54
I'm used to using jQuery's .append() method to add text or HTML onto the end of a pre-existing element. I'm currently using jQuery's .text() to escape strings that could potentially contain HTML. Unfortunately, there doesn't seem to be a jQuery method that will append the results of the .text() method to an element instead of replacing its contents. Is there a way to append, instead of replace, this escaped text to an element? Or is there a better way to escape strings containing HTML? Thanks. - EDIT - A little more context: I'm building an HTML string dynamically, and so I'll need to be able

Correct way to escape input data before passing to ODBC

与世无争的帅哥 提交于 2019-11-29 06:55:09
I am very used to using MySQL and mysql_real_escape_string(), but I have been given a new PHP project that uses ODBC. What is the correct way to escape user input in a SQL string? Is addslashes() sufficient? I would like to get this right now rather than later! Instead of string escaping the PHP ODBC driver uses prepared statements. Use odbc_prepare to prepare an SQL statement and odbc_execute to pass in the parameters and execute the statements. (This is similar to what you can do with PDO). 来源: https://stackoverflow.com/questions/5713837/correct-way-to-escape-input-data-before-passing-to

Why do I have to use double backslashes for file-paths in code?

徘徊边缘 提交于 2019-11-29 06:48:41
In my program I'm trying to open a file, for example C:\unescaped\backslashes.txt , but it fails to open! Why? What is this? This is a collection of common Q&A. This is also a Community Wiki, so everyone is invited to participate in maintaining it. Why is this? There are a lot of questions in the site which boil down to OP not knowing he/she needs to escape backslashes in file paths in the source code. The questions are usually "Why is my program not working?" or "Why is the file not found?", and somewhere in the source code there will be: const char *fileName = "C:\unescaped\backslashes.txt";

What is the difference between escapeXml and escapeHtml?

蓝咒 提交于 2019-11-29 05:40:54
I would like to escape characters in JSP pages. Which is more suitable, escapeXml or escapeHtml ? They're designed for different purposes, HTML has lots of entities that XML doesn't. XML only has 5 escapes: < represents "<" > represents ">" & represents "&" &apos; represents ' " represents " While HTML has loads - think of   © etc. These HTML codes aren't valid in XML unless you include a definition in the header. The numeric codes (like © for the copyright symbol) are valid in both. BalusC There's no such thing as escapeHtml in JSP. You normally use <c:out escapeXml="true"> (it by the way

Request Parameter Losing Plus Sign

本秂侑毒 提交于 2019-11-29 05:40:27
I am editing a search form and trying to protect against special characters in the database. In the JSP search form, a (multiselect) dropdown allows users to select descriptions that will be used in the query (note: descriptions is a list of strings): <select id="descriptionSelect" multiple="multiple"> <c:forEach items="${descriptions}" var="description"> <option value="${fn:escapeXml(description)}")}"> <c:out value="${description}" /> </option> </c:forEach> </select> When the form submits, the page dynamically generates the URL which takes query parameters in the URL (ugly, I know, hands are

Cannot get xslt to output an (&) even after escaping the character

别说谁变了你拦得住时间么 提交于 2019-11-29 05:34:44
I am trying to create a query string of variable assignments separated by the & symbol (ex: "var1=x&var2=y&..." ). I plan to pass this string into an embedded flash file. I am having trouble getting an & symbol to show up in XSLT. If I just type & with no tags around it, there is a problem rendering the XSLT document. If I type & with no tags around it, then the output of the document is & with no change. If I type <xsl:value-of select="&" /> or <xsl:value-of select="&" /> I also get an error. Is this possible? Note: I have also tried &amp; with no success. Kevin Hakanson You can combine

NodeJS Express encodes the URL - how to decode

こ雲淡風輕ζ 提交于 2019-11-29 05:31:23
问题 I'm using NodeJS with Express, and when I use foreign characters in the URL, they automatically get encoded. How do I decode it back to the original string? Before calling NodeJS, I escape characters. So the string: אובמה Becomes %u05D0%u05D5%u05D1%u05DE%u05D4 The entire URL now looks like: http://localhost:32323/?query=%u05D0%u05D5%u05D1%u05DE%u05D4 Now in my NodeJS, I get the escaped string %u05D0%u05D5%u05D1%u05DE%u05D4 . This is the relevant code: var url_parts = url.parse(req.url, true);