escaping

Create a mapping for Vim's command-line that escapes the contents of a register before inserting it

自闭症网瘾萝莉.ら 提交于 2020-01-01 09:08:06
问题 Suppose that I have a document like this, and I want to search for all occurences of the URL: Vim resources: [http://example.com/search?q=vim][q] ... [q]: http://example.com/search?q=vim I don't want to type it out in full, so I'll place my cursor on the first URL, and run "uyi[ to yank it into the 'u' register. Now to search for it, I'd like to just paste the contents of that register into the search field by running: /\V<c-r>u<CR> This results in Vim searching for the string 'http:' -

When to CDATA vs. Escape & Vice Versa?

試著忘記壹切 提交于 2020-01-01 08:03:41
问题 I'm creating XML documents with values fetched from a DB. Occasionally due to a legacy implementation, I'll pullback a value that contains a char that's invalid when not properly escaped (& for example). So the question becomes, should I CDATA or Escape? Are certain situations more appropriate for one vs. the other? Examples: <Email>foo&bar@domain.com</Email> I'd lean towards CDATA here. <Name>Bob & Tom</Name> I'd lean towards escaping here. I want to avoid blindly CDATA'ing every time, but

Where is the proper place to escape quotes in Play Framework?

余生颓废 提交于 2020-01-01 07:02:33
问题 I have the following flow: A user is presented with a form. He fills in the form fields, and submits to the controller, which persists this to the DB On another page, the Controller gets this record from the DB, and passes it to the view The view captures it as a javascript variable: var foo = '${user.bar}'; Now, if the user enters this string in the form: I have a quote - ' - very dangerous then the quote is passed through all the way to the DB and back, and results in a corrupt javascript

escaping html inside comment tags

大兔子大兔子 提交于 2020-01-01 05:40:29
问题 escaping html is fine - it will remove < 's and > 's etc. ive run into a problem where i am outputting a filename inside a comment tag eg. <!-- ${filename} --> of course things can be bad if you dont escape, so it becomes: <!-- <c:out value="${filename}"/> --> the problem is that if the file has "--" in the name, all the html gets screwed, since youre not allowed to have <!-- -- --> . the standard html escape doesnt escape these dashes, and i was wondering if anyone is familiar with a simple

Escaping a quote in findstr search string

我与影子孤独终老i 提交于 2020-01-01 04:51:06
问题 How can I properly escape a quote in a search string when using findstr.exe? Example: findstr /misc:"namespace=\"" *.cs > ns.txt This outputs to the console, instead of to the file I specified. I am doing this directly on the command line, not actually in a batch file, though that information might be useful too. 回答1: Please correct me if I'm wrong, but I think I've figured it out: findstr.exe /misc:^"namespace=\^"^" *.cs > ns.txt This seems to give the correct output, even if you have spaces

Escaping html in Java

时光总嘲笑我的痴心妄想 提交于 2020-01-01 04:17:12
问题 How do I make sure I don't escape something twice? I've heard that its good practice to escape values as you receive them from a form, and also escape when you output. That way you have two chances to catch something. 回答1: I presume that you're using JSP. Just escape during display only. There for the JSTL <c:out> tag is perfectly suitable. It escapes HTML entities by default. Use it to display every user-controlled input, such as request URL, request headers and request parameters. E.g.

Do jQuery's val() and prop() methods html-escape values?

一个人想着一个人 提交于 2020-01-01 04:06:57
问题 I can't find anything in the documentation about val() and prop() and escaping. Are they intended to escape values when used as setters? 回答1: Not really. .val() is used to set a form field's value attribute, so escaping isn't really necessary there. You'll be setting the value via the DOM, so it's not like you're constructing HTML through string concatenation. .prop() , on the other hand, doesn't even interact with attributes at all - just DOM properties, so you don't need to working about

Spring: escaping input when binding to command

与世无争的帅哥 提交于 2019-12-31 10:47:16
问题 How do you handle the case where you want user input from a form to be htmlEscape'd when you are binding to a command object? I want this to sanitize input data automatically in order to avoid running through all fields in command object. thanks. 回答1: If you are using a FormController you can register a new property editor by overriding the initBinder(HttpServletReques, ServletRequestDataBinder) method. This property editor can escape the html, javascript and sql injection. If you are using a

Scala: How can I get an escaped representation of a string?

主宰稳场 提交于 2019-12-31 09:15:09
问题 Basically, what I'd like to do is have: // in foo.scala val string = "this is a string\nover two lines" println(string) println(foo(string)) Do this: % scala foo.scala this is a string over two lines "this is a string\nover two lines" Basically looking for an analog of ruby's String#inspect or haskell's show :: String -> String . 回答1: This question is a bit old but I stumbled over it while searching for a solution myself and was dissatisfied with the other answers because they either are not

Escaped characters in string from submitted form

痞子三分冷 提交于 2019-12-31 05:44:07
问题 Every time a POST is made I get escaped characters. \ -> \\ ' -> \' " -> \" I have a multistep form, which transmits the data from one form to another. I save the values with prepared statments in the database. The values in the database currently look like Paul\'s House . User should have the possiblity to use single and double quotes in their string. This is a simple example demonstrating the escaping effect: <?php echo $_POST['value']; ?> <form action="form.php" method="post" enctype=