escaping

How do I textile and sanitize html?

荒凉一梦 提交于 2019-12-18 05:05:03
问题 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.

passing quoted arguments from batch file to `powershell start` - self-elevation on demand

允我心安 提交于 2019-12-18 04:23:14
问题 I am writing a Windows batch file that automatically escalates itself to administrative permissions, provided the user clicks "Yes" on the User Access Control dialog that appears. I am using a technique I learned here to detect whether we already have admin rights and another from here to escalate. When appropriate, the following script, let's call it foo.bat , re-launches itself via a powershell-mediated call to runas : @echo off net session >NUL 2>NUL if %ERRORLEVEL% NEQ 0 ( powershell

Raw string and regular expression in Python

て烟熏妆下的殇ゞ 提交于 2019-12-18 04:19:09
问题 I have some confusions regarding raw string in the following code: import re text2 = 'Today is 11/27/2012. PyCon starts 3/13/2013.' text2_re = re.sub(r'(\d+)/(\d+)/(\d+)', r'\3-\1-\2', text2) print (text2_re) #output: Today is 2012-11-27. PyCon starts 2013-3-13. print (r'(\d+)/(\d+)/(\d+)') #output: (\d+)/(\d+)/(\d+) As how I understand the raw string, without r , the \ is treated as escape character; with r , the backslash \ is treated as itself literally. However, what I cannot understand

JSON.stringify doesn't escape?

做~自己de王妃 提交于 2019-12-18 03:57:20
问题 I'm using `JSON.stringify? to stringify an object, but the quotes are not escaped? Am I misunderstanding that it's suppose to escape the quotes? This is outputted into the template without any of the quotes being escaped: {"console":{"free":false}} 回答1: The quotes around property names are not supposed to be escaped, only quotes inside strings. Your JSON is fine :) 回答2: It doesn't escape characters, no, there's encodeURIComponent for that, and you can use them together, as in

How to include an ampersand (&) in the content of a ComboBoxItem

纵然是瞬间 提交于 2019-12-18 03:51:51
问题 I currently have a Combobox like the following: //XAML <ComboBox> <ComboBoxItem> Awake & Alive</ComboBoxItem> </ComboBox> This raises an error: Entity references or sequences beginning with an ampersand '&' must be terminated with a semicolon ';'. I assume I am missing an escape sequence of some sort to allow me to use a &. How can I set the content of this comboboxitem to include a &? 回答1: Use & to encode the ampersand. //XAML <ComboBox> <ComboBoxItem> Awake & Alive</ComboBoxItem> </ComboBox

How to include an ampersand (&) in the content of a ComboBoxItem

半腔热情 提交于 2019-12-18 03:51:41
问题 I currently have a Combobox like the following: //XAML <ComboBox> <ComboBoxItem> Awake & Alive</ComboBoxItem> </ComboBox> This raises an error: Entity references or sequences beginning with an ampersand '&' must be terminated with a semicolon ';'. I assume I am missing an escape sequence of some sort to allow me to use a &. How can I set the content of this comboboxitem to include a &? 回答1: Use & to encode the ampersand. //XAML <ComboBox> <ComboBoxItem> Awake & Alive</ComboBoxItem> </ComboBox

Java Regex for matching quoted string with escaped quotes

妖精的绣舞 提交于 2019-12-18 03:39:31
问题 I know there are already many questions like mine but I found no answer which works in Java. So I write a new question. I have text files with content like this: key1 = "This is a \"test\" text with escapes using '\\' characters"; key2 = 'It must work with \'single\' quotes and "double" quotes'; I need a regular expression which matches the values in the double-quotes (or single-quotes). This regular expression must support the escaped quotes and escaped backslashes. The regular expression

Java is not treating “\n” as new line when retrieved from Database column

与世无争的帅哥 提交于 2019-12-18 03:35:20
问题 I am facing a weird problem. What I am doing is I am storing some values in DB(oracle 11g) as varchar2 and fetching the values in java and working with the fetched data. Now I have \n as a value in DB and getting it in java using rs.getString() . I am getting proper value \n . String newLine=rs.getString("column_value"); Now i parse a HTML page and get the whole page as a string.Suppose the page has 3 lines each depiciting ssome informations like below: Time: 08 AM - 11 AM Duration : 36

Passing arguments to a command in Bash script with spaces

随声附和 提交于 2019-12-18 03:31:06
问题 I'm trying to pass 2 arguments to a command and each argument contains spaces, I've tried escaping the spaces in the args, I've tried wrapping in single quotes, I've tried escaping \" but nothing will work. Here's a simple example. #!/bin/bash -xv ARG="/tmp/a b/1.txt" ARG2="/tmp/a b/2.txt" ARG_BOTH="\"$ARG\" \"$ARG2\"" cat $ARG_BOTH I'm getting the following when it runs: ARG_BOTH="$ARG $ARG2" + ARG_BOTH='/tmp/a\ b/1.txt /tmp/a\ b/2.txt' cat $ARG_BOTH + cat '/tmp/a\' b/1.txt '/tmp/a\' b/2.txt

Escaping single quote in String.Format()

走远了吗. 提交于 2019-12-18 03:03:30
问题 I have been all over the 'tubes and I can't figure this one out. Might be simple. The following String.Format call: return dt.ToString("MMM d yy 'at' H:mmm"); Correctly returns this: Sep 23 08 at 12:57 Now let's say I want to add a single quote before the year, to return this: Sep 23 '08 at 12:57 Since the single quote is a reserved escape character, how do I escape the single quote to get it to display? I have tried double, triple, and quad single quotes, with no luck. 回答1: You can escape it