escaping

XSL character escape problem

早过忘川 提交于 2019-12-18 07:45:23
问题 I am writing this because I have really hit the wall and cannot go ahead. In my database I have escaped HTML like this: "<p>My name is Freddy and I was" . I want to show it as HTML OR strip the HTML tags in my XSL template. Both solutions will work for me and I will choose the quicker solution. I have read several posts online but cannot find a solution. I have also tried disable-output-escape with no success. Basically it seems the problem is that somewhere in the XSL execution the engine is

Handling regex escape replacement text that contains the dollar character

﹥>﹥吖頭↗ 提交于 2019-12-18 07:29:10
问题 string input = "Hello World!"; string pattern = "(World|Universe)"; string replacement = "$1"; string result = Regex.Replace(input, pattern, replacement); Having the following example, the result would be "Hello World!" , as the $1 gets replaced with the first group (World|Universe) , however the result I want is "Hello $1!" The Regex.Escape method is meant to be used to escape a Regex pattern, not the replacement, as it can escape other characters like slashes and other Regex pattern

spaces in bash variable path name

两盒软妹~` 提交于 2019-12-18 07:05:34
问题 Ugh. I hate bash escape sequences. What's the proper way to do this? $ export SUBLPKG=~/"Library/Application Support/Sublime Text 2/Packages" $ cd $SUBLPKG -bash: cd: /Users/$ME/Library/Application: No such file or directory $ export SUBLPKG=~/"Library/Application\ Support/Sublime\ Text\ 2/Packages" $echo $SUBLPKG /Users/$ME/Library/Application\ Support/Sublime\ Text\ 2/Packages $ cd $SUBLPKG -bash: cd: /Users/$ME/Library/Application\: No such file or directory I want to break all the things.

How to escape output in PHP

你离开我真会死。 提交于 2019-12-18 06:58:15
问题 I am a newbie, just to be clear. I hear a lot about escaping data to prevent XSS attacks. How do I actually do that? This is what I am doing currently - $s = mysqli_real_escape_string($connect,$_POST['name'])); Is this enough? Thanks 回答1: If you output the data to html you should use htmlspecialchars() else, if you're storing the data in a database you should escape strings using mysqli_real_escape_string() and cast numbers (or use prepared statements for both) and protect identifiers

Force repr() to use single quotes

五迷三道 提交于 2019-12-18 06:48:46
问题 I have a question, is there a way to "force" repr() to create always single quotes around a string? This happens when I only use repr() print repr("test") 'test' print repr("test'") "test'" print repr("test\"") 'test"' print repr("test'\"") 'test\'"' so the last one actually does, what I want, but I don't want to add always \\" to get the single quotes. Edit: I am not going to mark an answer as accepted since, as pointed out by @martijn-pieters, I was using repr() for purposes it is not

Regex and escaped and unescaped delimiter

混江龙づ霸主 提交于 2019-12-18 06:01:10
问题 question related to this I have a string a\;b\\;c;d which in Java looks like String s = "a\\;b\\\\;c;d" I need to split it by semicolon with following rules: If semicolon is preceded by backslash, it should not be treated as separator (between a and b ). If backslash itself is escaped and therefore does not escape itself semicolon, that semicolon should be separator (between b and c ). So semicolon should be treated as separator if there is either zero or even number of backslashes before it.

need to escape # (hash/pound) character in .htaccess rewrite rule

寵の児 提交于 2019-12-18 05:44:14
问题 The question is fairly simple but I was not able to find an answer for hours now. What I need to do is: RewriteRule ([^#])#(.*) $1\%23$2 Which basically means I want to url escape the freaking hash sign which comes to me from an external codepiece. backslash ( \ ) does not work to escape this sign... and please don't suggest using %23 instead # because it does not work as well. ( %2 3 does not match a # because it simply is not == %23 ) 回答1: The hash part of a URL is not available for

How to read until ESC button is pressed from cin in C++

狂风中的少年 提交于 2019-12-18 05:17:16
问题 I'm coding a program that reads data directly from user input and was wondering how could I read all data until ESC button on keyboard is pressed. I found only something like this: std::string line; while (std::getline(std::cin, line)) { std::cout << line << std::endl; } but need to add a portable way (Linux/Windows) to catch a ESC button pressed and then break a while loop. How to do this? EDIT: I wrote this, but still - works even if I press an ESC button on my keyboard: #include <iostream>

Why I need to double-escape (use 4 \) to find a backslash ( \ ) in pure SQL?

对着背影说爱祢 提交于 2019-12-18 05:12:15
问题 I do not understand this MySQL behaviour : if I want to display a\b, I can just select "a\\b" which work without problem : mysql> select "a\\b"; +-----+ | a\b | +-----+ | a\b | +-----+ 1 row in set (0.05 sec) But if I wnat to search a string containing a \ in a table using LIKE, I need to double-escape my "\". Why ? Here is an example. We prepare a small table. create table test ( test varchar(255) ); insert into test values ( "a\\b" ) , ( "a\\b\\c" ) , ( "abcd" ); mysql> select * from test;

How do I textile and sanitize html?

允我心安 提交于 2019-12-18 05:05:26
问题 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.