escaping

How do I automatically fix an invalid JSON string?

拜拜、爱过 提交于 2019-12-17 04:03:10
问题 From the 2gis API I got the following JSON string. { "api_version": "1.3", "response_code": "200", "id": "3237490513229753", "lon": "38.969916127827", "lat": "45.069889625267", "page_url": null, "name": "ATB", "firm_group": { "id": "3237499103085728", "count": "1" }, "city_name": "Krasnodar", "city_id": "3237585002430511", "address": "Turgeneva, 172/1", "create_time": "2008-07-22 10:02:04 07", "modification_time": "2013-08-09 20:04:36 07", "see_also": [ { "id": "3237491513434577", "lon": 38

How to escape the equals sign in properties files

做~自己de王妃 提交于 2019-12-17 04:02:23
问题 How can I escape the equals sign ( = ) in Java property files? I would like to put something as the following in my file: table.whereclause=where id=100 回答1: Moreover, Please refer to load(Reader reader) method from Property class on javadoc In load(Reader reader) method documentation it says The key contains all of the characters in the line starting with the first non-white space character and up to, but not including, the first unescaped '=' , ':' , or white space character other than a

How to escape the equals sign in properties files

大憨熊 提交于 2019-12-17 04:02:01
问题 How can I escape the equals sign ( = ) in Java property files? I would like to put something as the following in my file: table.whereclause=where id=100 回答1: Moreover, Please refer to load(Reader reader) method from Property class on javadoc In load(Reader reader) method documentation it says The key contains all of the characters in the line starting with the first non-white space character and up to, but not including, the first unescaped '=' , ':' , or white space character other than a

How to receive even the strangest command line parameters?

心已入冬 提交于 2019-12-17 04:00:24
问题 as discussed in an other thread How to avoid cmd.exe interpreting shell special characters like < > ^ it is not easy to get all parameters from the command line. A simple set var=%1 set "var=%~1" are not enough, if you have a request like myBatch.bat abc"&"^&def I have one solution, but it needs a temporary file, and it is also not bullet proof. @echo off setlocal DisableDelayedExpansion set "prompt=X" ( @echo on for %%a in (4) do ( rem #%1# ) ) > XY.txt @echo off for /F "delims=" %%a in (xy

Sanitizing user input before adding it to the DOM in Javascript

我的梦境 提交于 2019-12-17 03:09:43
问题 I'm writing the JS for a chat application I'm working on in my free time, and I need to have HTML identifiers that change according to user submitted data. This is usually something conceptually shaky enough that I would not even attempt it, but I don't see myself having much of a choice this time. What I need to do then is to escape the HTML id to make sure it won't allow for XSS or breaking HTML. Here's the code: var user_id = escape(id) var txt = '<div class="chut">'+ '<div class="log" id=

Efficiently convert backslash to forward slash in R

ぐ巨炮叔叔 提交于 2019-12-17 02:59:34
问题 I am looking for an efficient way to convert back slash to forward slash in R. Sometime I copy the link of the directory from the windows and I get something like this: C:\Users\jd\Documents\folder\file.txt How can I quickly change this to C:/Users/jd/Documents/folder/file.txt ? I cannot even read the above expression as character. It throws an error "\u used without hex digits in character string starting ""C:\u". I know TAB function in R helps to find the location fast, but was just

Escape invalid XML characters in C#

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-17 02:45:10
问题 I have a string that contains invalid XML characters. How can I escape (or remove) invalid XML characters before I parse the string? 回答1: As the way to remove invalid XML characters I suggest you to use XmlConvert.IsXmlChar method. It was added since .NET Framework 4 and is presented in Silverlight too. Here is the small sample: void Main() { string content = "\v\f\0"; Console.WriteLine(IsValidXmlString(content)); // False content = RemoveInvalidXmlChars(content); Console.WriteLine

How to escape single quotes in Bash/Grep?

主宰稳场 提交于 2019-12-17 02:37:41
问题 I want to search with grep for a string that looks like this: something ~* 'bla' I tried this, but the shell removes the single quotes argh.. grep -i '"something ~* '[:alnum:]'"' /var/log/syslog What would be the correct search? 回答1: grep -i "something ~\* '[[:alnum:]]*'" /var/log/syslog works for me. escape the first * to match a literal * instead of making it the zero-or-more-matches character: ~* would match zero or more occurrences of ~ while ~\* matches the expression ~* after something

Dollar ($) sign in password string treated as variable

我只是一个虾纸丫 提交于 2019-12-17 02:37:15
问题 Spent some time troubleshooting a problem whereby a PHP/MySQL web application was having problems connecting to the database. The database could be accessed from the shell and phpMyAdmin with the exact same credentials and it didn't make sense. Turns out the password had a $ sign in it: $_DB["password"] = "mypas$word"; The password being sent was "mypas" which is obviously wrong. What's the best way to handle this problem? I escaped the $ with a \ $_DB["password"] = "mypas\$word"; and it

Escaping MySQL wild cards

一曲冷凌霜 提交于 2019-12-17 01:46:47
问题 On an older server I'm using that I can't use prepared statements on I am currently trying to fully escape user input before sending it to MySQL. For this I am using the PHP function mysql_real_escape_string . Since this function does not escape the MySQL wildcards % and _ I am using addcslashes to escape these as well. When I send something like: test_test " ' to the database and then read it back the database shows: test\_test " ' Looking at this I can't understand why the _ has a preceding