escaping

Escape all strings in JSP/Spring MVC

心不动则不痛 提交于 2019-12-18 11:21:58
问题 I display strings in my JSP this way: ${someString} this string may, of course, contain special html characters. Currently it is possible to HTML-inject malicious code (eg. if someString is a javascript include - <script src...> ). How can I make sure that all strings are escaped before printing? I am using Spring MVC and JSP. 回答1: You can use JSTL core : <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> Use <c:out value="${someString}"/> tag to display Strings. <c:out> escapes

Escaping single quotes in JavaScript string for JavaScript evaluation

天大地大妈咪最大 提交于 2019-12-18 11:00:48
问题 I have a project, in which some JavaScript var is evaluated. Because the string needs to be escaped (single quotes only), I have written the exact same code in a test function. I have the following bit of pretty simple JavaScript code: function testEscape() { var strResult = ""; var strInputString = "fsdsd'4565sd"; // Here, the string needs to be escaped for single quotes for the eval // to work as is. The following does NOT work! Help! strInputString.replace(/'/g, "''"); var strTest =

Can't escape escape characters in string

▼魔方 西西 提交于 2019-12-18 09:37:05
问题 In an attempt to answer this question, I managed to get the string to print the escape characters by escaping the backslash. When I try to generalize it to escape all escaped characters, it seems to do nothing: >>> a = "word\nanother word\n\tthird word" >>> a 'word\nanother word\n\tthird word' >>> print a word another word third word >>> b = a.replace("\\", "\\\\") >>> b 'word\nanother word\n\tthird word' >>> print b word another word third word but this same method for specific escape

Batch: Auto escape special characters

我是研究僧i 提交于 2019-12-18 09:17:55
问题 As far as I know, I need to escape every escape characters when echoing them. The ^ method works fine for a few echo es. (which should be something like:) @echo ^| @echo ^> ^>^> However, when there are a lot of characters to escape, the ^ method won't work anymore. So, my question is: Are there any ways escape all special characters without "spamming" the caret? 回答1: Well, there is no need to escape redirection operators and other special characters listed in last paragraph in help output by

How the preg_match handles the delimiter when \Q..\E used?

只谈情不闲聊 提交于 2019-12-18 09:02:46
问题 I'm playing with regular expressions and I tried the \Q..\E escape sequence. First try: $regex = '/\Q http:// \E/'; var_dump(preg_match($regex, ' http:// ')); It tells me that '\' is unknown modifier, completely understandable. Second try: $regex = '/\Q http:\/\/ \E/'; var_dump(preg_match($regex, ' http:// ')); var_dump(preg_match($regex, ' http:\/\/ ')); It runs, not match the first string, but match the second one. I know that I could use other delimiter character or solve it without \Q..\E

When do I need to escape metacharectars? (jQuery Selectors)

混江龙づ霸主 提交于 2019-12-18 08:34:27
问题 According to the jQuery docs, I need to escape metacharacters that occur in my selector strings, when they occur as a literal. However, I couldn't find very many specific examples of when and when not to escape selectors. So when and when don't I need to escape metacharacters, when they are to be interpreted as a literal, in: Attribute selectors? ie $("[attr=value]") Id selectors? ie $("#id") Class selectors? ie $(".class"); And, is there a way to write a function that replaces metachars in

When do I need to escape metacharectars? (jQuery Selectors)

浪子不回头ぞ 提交于 2019-12-18 08:33:51
问题 According to the jQuery docs, I need to escape metacharacters that occur in my selector strings, when they occur as a literal. However, I couldn't find very many specific examples of when and when not to escape selectors. So when and when don't I need to escape metacharacters, when they are to be interpreted as a literal, in: Attribute selectors? ie $("[attr=value]") Id selectors? ie $("#id") Class selectors? ie $(".class"); And, is there a way to write a function that replaces metachars in

TinyMCE disable escaping

混江龙づ霸主 提交于 2019-12-18 08:32:17
问题 I'm using tinyMCE to edit content from an existing website. This website has links in the format: http://localhost/start.jsp%3Fparam=value where the %3F is the escaped string for the question mark character. When TinyMCE edits a page containing one of these links, it converts the "%" sign into "%25" which breaks the link. How can I disable tinyMCE's escaping of percent signs? I have the following configuration set: tinyMCE.init({ mode: "specific_textareas", editor_encoding: "raw", editor

TinyMCE disable escaping

不打扰是莪最后的温柔 提交于 2019-12-18 08:32:09
问题 I'm using tinyMCE to edit content from an existing website. This website has links in the format: http://localhost/start.jsp%3Fparam=value where the %3F is the escaped string for the question mark character. When TinyMCE edits a page containing one of these links, it converts the "%" sign into "%25" which breaks the link. How can I disable tinyMCE's escaping of percent signs? I have the following configuration set: tinyMCE.init({ mode: "specific_textareas", editor_encoding: "raw", editor

How do you escape double quotes inside a SQL fulltext 'contains' function?

十年热恋 提交于 2019-12-18 08:12:22
问题 How do you escape a double quote character inside a MS SQL 'contains' function? SELECT decision FROM table WHERE CONTAINS(decision, '34" AND wide') Normally contains() expects double quotes to surround an exact phrase to match, but I want to search for an actual double quote character. I've tried escaping it with \, `, and even another double quote, but none of that has worked. P.S. I realize a simple example like this could also be done using the LIKE statement, but I need to use the