escaping

What exactly do I have to escape inside a `script` element?

南笙酒味 提交于 2019-12-29 05:20:08
问题 What parts of JavaScript code do I have to escape inside a script element in a HTML page? Is <>& enough or too much? [EDIT] This is related to this bug: http://code.google.com/p/rendersnake/issues/detail?id=15#c6 comment #6 回答1: In HTML (and XHTML if you're an evil person that sends your XHTML pages as text/html ), script tags are #CDATA , and therefore, the only thing that you shouldn't have in the content is </script> , as that is all that the parser looks for to signal the end of the tag.

How to properly escape html sent as data in jQuery's .ajax function

走远了吗. 提交于 2019-12-29 01:34:51
问题 UPDATE : Once I looked at the problem in Firebug, I found my mistake immediately. And it was an embarrassing unmatched double quote that I must have deleted somehow. I had been using Chrome's developer window. Very sorry for using up your resources. But, lesson learned! ("I hope.) What is the best way for me to escape html characters that I want to send to my server? I am using jQuery, .ajax(), and jsonp. I'm writing a bookmarklet which sends parts of the current page's html to my server.

Unescaped control characters in NSJSONSerialization

浪子不回头ぞ 提交于 2019-12-28 16:02:29
问题 I have this JSON http://www.progmic.com/ielts/retrive.php that I need to parse. When I do it with NSJSONSerialization, I get "Unescaped control character around character 1981" error. I need to know: What the heck are the unescaped control characters? Is there a list or something? How do I get rid of this error? The easiest way? Thanks in advance. 回答1: I added this method to remove the unescaped characters from retrieved string: - (NSString *)stringByRemovingControlCharacters: (NSString *

Exact string match in vim? (Like 'regex-off' mode in less.)

*爱你&永不变心* 提交于 2019-12-28 12:57:28
问题 In vim , I often want to search on a string with finicky characters which need escaping. Is there a way I can turn off the meaning of all special characters, kind of like regex-off mode in less, or fgrep ? I am dealing with particularly hairy strings; here's an example: ((N/N)/(N/N))/N Not having to escape any characters to do a search in vim would be a major timesaver. \V in Vim helps with some metacharacters, but critically not / or \. Thanks all! In the end, I added this to my .vimrc:

Escaping javascript string in java

。_饼干妹妹 提交于 2019-12-28 06:42:07
问题 I need to make this into a string in java: <script type="text/javascript">document.write("<img src=\"UpArrow.png\" /> \"); </script> Can someone help? I keep trying and it ends up like this... return "<script type=\"text/javascript\">document.write(\"<img src=\"UpArrow.png\" /> \"); </script>"; Which doesn't work because I need to double escape the quotes before and after UpArrow.png. since it needs to be escaped in javascript and not in java. . . 2019 Update: If you are looking at this, god

Creating an Uri in .NET automatically urldecodes all parameters from passed string

你说的曾经没有我的故事 提交于 2019-12-28 06:34:45
问题 Suppose I want to create an Uri object from the following string: string url = @"http://someserver.com?param1=1&url=http%3a%2f%2fwww.otherserver.com"; Uri uri = new Uri(url, UriKind.Absolute); Expected result would be: http://someserver.com?param1=1&url=http%3a%2f%2fwww.otherserver.com Obtained: http://someserver.com/?param1=1&url=http://www.otherserver.com The same behavior is noticed in many related methods that allow Uri creation: Uri.TryCreate, UriBuilder.Uri, etc. How would I get an Uri

Escaping special characters in cmd

自作多情 提交于 2019-12-28 04:18:07
问题 I have a Windows .bat script in which I try to run a command with password in parameter. The password I want to be able to use is ~!@#$%^&*()_+|-=\][{}';:"/.>?,< . From what I've read here, I should escape ^&|\<> with ^ . From what I assume, I should escape " with \" . This gives me something like that: runme.exe /password:"~!@#$%^^^&*()_+^|-=^\][{}';:\"/.^>?,^<" But it doesn't work - my target app responds with logon failure. How should I escape all these characters to be able to hardcode

Java Runtime exec() fails to escape characters properly

荒凉一梦 提交于 2019-12-28 04:07:10
问题 This might already been answered before but that was regarding unicode and I don't think this is unicode (it's in ASCII so...). When I execute this in my terminal there is no problem what so ever vboxmanage setextradata "Test Machine" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 2222 However when I use the following in Java Runtime.getRuntime().exec("vboxmanage setextradata \"Test Machine\" \"VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort\" 2222"); It returns an error:

How do you escape colon (:) in Properties file?

不打扰是莪最后的温柔 提交于 2019-12-28 03:05:41
问题 I am using a properties file to store my application's configuration values. In one of the instances, I have to store a value as xxx:yyy:zzz . When I do that, the colon is escaped with a back slash \ resulting in the value showing as xxx\:yyy\:zzz in the properties file. I am aware that the colon : is a standard delimiter of the Properties Java class. However I still need to save the value without the back slash \ . Any suggestions on how to handle this? 回答1: Put the properties into the

How do you escape colon (:) in Properties file?

旧巷老猫 提交于 2019-12-28 03:05:15
问题 I am using a properties file to store my application's configuration values. In one of the instances, I have to store a value as xxx:yyy:zzz . When I do that, the colon is escaped with a back slash \ resulting in the value showing as xxx\:yyy\:zzz in the properties file. I am aware that the colon : is a standard delimiter of the Properties Java class. However I still need to save the value without the back slash \ . Any suggestions on how to handle this? 回答1: Put the properties into the