escaping

Decode escaped characters in URL

佐手、 提交于 2019-12-17 01:00:03
问题 I have a list containing URLs with escaped characters in them. Those characters have been set by urllib2.urlopen when it recovers the html page: http://www.sample1webpage.com/index.php?title=%E9%A6%96%E9%A1%B5&action=edit http://www.sample1webpage.com/index.php?title=%E9%A6%96%E9%A1%B5&action=history http://www.sample1webpage.com/index.php?title=%E9%A6%96%E9%A1%B5&variant=zh Is there a way to transform them back to their unescaped form in python? P.S.: The URLs are encoded in utf-8 回答1:

Unrecognized escape sequence for path string containing backslashes

纵然是瞬间 提交于 2019-12-16 22:46:47
问题 The following code generates a compiler error about an "unrecognized escape sequence" for each backslash: string foo = "D:\Projects\Some\Kind\Of\Pathproblem\wuhoo.xml"; I guess I need to escape backslash? How do I do that? 回答1: You can either use a double backslash each time string foo = "D:\\Projects\\Some\\Kind\\Of\\Pathproblem\\wuhoo.xml"; or use the @ symbol string foo = @"D:\Projects\Some\Kind\Of\Pathproblem\wuhoo.xml"; 回答2: Try this: string foo = @"D:\Projects\Some\Kind\Of\Pathproblem

How do I escape the wildcard/asterisk character in bash?

别说谁变了你拦得住时间么 提交于 2019-12-16 22:45:54
问题 For example: me$ FOO="BAR * BAR" me$ echo $FOO BAR file1 file2 file3 file4 BAR and using the \ escape character: me$ FOO="BAR \* BAR" me$ echo $FOO BAR \* BAR I'm obviously doing something stupid. How do I get the output BAR * BAR ? 回答1: Quoting when setting $FOO is not enough. You need to quote the variable reference as well: me$ FOO="BAR * BAR" me$ echo "$FOO" BAR * BAR 回答2: SHORT ANSWER Like others have said - you should always quote the variables to prevent strange behaviour. So use echo

Objective C HTML escape/unescape

眉间皱痕 提交于 2019-12-16 20:03:52
问题 Wondering if there is an easy way to do a simple HTML escape/unescape in Objective C. What I want is something like this psuedo code: NSString *string = @"<span>Foo</span>"; [string stringByUnescapingHTML]; Which returns <span>Foo</span> Hopefully unescaping all other HTML entities as well and even ASCII codes like Ӓ and the like. Is there any methods in Cocoa Touch/UIKit to do this? 回答1: This link contains the solution below. Cocoa CF has the CFXMLCreateStringByUnescapingEntities function

Searching using MySQL: How to escape wildcards

空扰寡人 提交于 2019-12-14 04:19:45
问题 I am currently searching my database with a query (using JDBC) like this: "... AND LCASE(Items.Name) LIKE '%" + searchString.toLowerCase() + "%';" Now, this is obviously very bad, because it allows for SQL injection as well as insertion of wildcard symbols such as % and _. My question is, how can I do a query such that even if the searchString contains any of these characters, they will be treated literally? 回答1: First, don't use LCASE with LIKE unless you're using a case-sensitive locale

How to escape-html in JSP before saving to database?

你离开我真会死。 提交于 2019-12-14 03:43:17
问题 I am learning JSP and Java at the moment and wrote a (very) simple guestbook to get started with JSP. But i want to ensure that noone can use CSS, so i need to strip the HTML code before saving it to my mySQL database. I already searched here and found the " PreparedStatement pStmt = conn.prepareStatement("INSERT INTO test VALUES (ID, ?, ?)"); pStmt.setString(1, request.getParameter("sender")); pStmt.setString(2, request.getParameter("text")); pStmt.executeUpdate(); So what would be the

jade html escaped string

a 夏天 提交于 2019-12-14 03:03:48
问题 I have a problema with Jade, I take an unescaped string from db (something like this: "<mo>&amp" this string can contain some html code, I pass the string to the page with res.render('page',f(){}) from the layout I stamp the string with !{t.text} but the html code is not rendered, seems that prints plain text. where is the error? 回答1: I've set up default express app which uses jade as its template engine. Modified routes -> index.js to pass some encoded text router.get('/', function(req, res)

How to escape a variable in Bash when passing to a command-line argument

纵然是瞬间 提交于 2019-12-14 02:53:30
问题 I've got a Bash script (Cygwin) that uses some Windows paths with spaces in them. Consequently, I have escaped the space with a \ in my variable definition. Everything within the script works fine. However, I need to pass this variable as an argument to a command-line executable. When I do that, my escaping gets messed up. Sample non-functional script: #!/bin/sh # File paths destinationPath="/cygdrive/c/Documents and Settings/Eric/My Documents/" attachments="\n2013-12-12.pdf" body="Test Body"

Why does the addslashes() function not work on my array in php?

核能气质少年 提交于 2019-12-14 02:38:51
问题 I have a series of session variables in an array. When I use quotes in one of my string variables, I try to addslashes so I can eventually insert it into the DB, but the addslashes() function is not working. Here is an example. In the comments field, I write this: This is the "comment" I realize this is a problem so I added a function before I enter it into the database that runs through a series of Session variables, including the comments variable. $strip_fields = array($_SESSION['comments'

Sinatra/Rack `ERROR URI::InvalidURIError: bad URI(is not URI?)` on redirect

我怕爱的太早我们不能终老 提交于 2019-12-14 02:33:46
问题 I've just started my first Sinatra project, a simple TV-show management web app, and wanted to have beautiful URLs. So when a user types in the search box and submits, I don't want to have a /?search=foobar -style URL and want do redirect them to /search/foobar . This also enables me to separate the get '/search/:name route from the main get '/' route. I've implemented the redirect using a before filter and properly escaped the params[] variable: before do if params.has_key? 'search' redirect