escaping

Angularjs - equal sign in $http post data

纵然是瞬间 提交于 2019-12-05 21:38:44
I'm using angularjs' $http service to post data to my API. It works great.. until I add and equals sign to the contents of data (JSONRequest in example) var request = { 'method': 'POST', 'url': API_URL + apiActionName, 'data': JSONRequest, 'withCredentials': true, }; $http(request). success(function(data, status, headers, config) { // handle success }). error(function(data, status, headers, config) { // handle error } this works for data contain the following JSONRequest { 'text':'this is some text' } however when the data contains this { 'text':'this is = some text' } the request is escaped

Escape characters when executing powershell command in batch script

前提是你 提交于 2019-12-05 21:09:12
I want to execute powershell command and put it in batch variable The command: for /f "delims=" %%i in ('powershell ^(Get-ChildItem ""\dir\"" -Name | sort-object {\[regex\]::Replace^($_,^'\d+^',{$args\[0\].Value.PadLeft^(20^)}^)} | select -last 1^) ') do set output=%%i It can't be executed due special character. In addition, I can't pause the window so it closes before I can see what is the problem. I think the problem is with the pipe "|", because the following command does work(the part before the pipe) for /f "delims=" %%i in ('powershell ^(Get-ChildItem ""\dir\"" -Name^) ') do set output=%

symfony2 twig whitelist html tags

Deadly 提交于 2019-12-05 19:02:30
问题 I pass a variable to my twig template in Symfony2, this variable may contain <br /> html tags, I have tried to create an extension (function), but the variable still gets escaped. How can I output a twig variable that allows the <br /> tag? Is there a simple solution to just allow a whitelist of allowed tags in certain templates? I've searched about twig sandboxes, but I'm not sure if that is my solution. edit: I still want the variable to be escaped, but to allow exclusively the <br /> tag.

Put $$ in dollar-quoted string in PostgreSQL

前提是你 提交于 2019-12-05 18:40:40
I have a function in Postgres: CREATE OR REPLACE FUNCTION upsert(sql_insert text, sql_update text) RETURNS integer AS $BODY$ BEGIN EXECUTE sql_insert; RETURN 1; EXCEPTION WHEN unique_violation THEN EXECUTE sql_update; RETURN 2; END; $BODY$ LANGUAGE 'plpgsql' VOLATILE COST 100; ALTER FUNCTION upsert(text, text) OWNER TO dce; I usually use this query to call that function: select upsert( $$INSERT INTO zz(a, b) VALUES (66, 'hahahaha')$$, $$UPDATE zz SET a=66, b='hahahaha' WHERE a=66$$ ) It works. Unfortunately, my query string cannot contain $$ , like this: select upsert( $$INSERT INTO zz(a, b)

Custom replace for json encoding not outputting double quotes as expected

我们两清 提交于 2019-12-05 18:38:02
After I created my own json encoder, I realized it was replacing double-quotes with two escaping backslashes instead of one. I realize, now, that C# has a built in Json.Encode() method, and yes, I have gotten it to work, however, I am left baffled by why the following code (the json encoder I had built) didn't replace quotes as I would expect. Here is my json encoder method: public static string jsonEncode(string val) { val = val.Replace("\r\n", " ") .Replace("\r", " ") .Replace("\n", " ") .Replace("\"", "\\\"") .Replace("\\", "\\\\"); return val; } The replace call: Replace("\"", "\\\"") is

Forward slashes in the names returned by JNDI query to LDAP server

…衆ロ難τιáo~ 提交于 2019-12-05 18:16:52
I need to make several queries to LDAP directory server and I'm using JNDI directory facilities for it. Then I need to do some work with the objects from the query result using their distinguished names. Some of the entries returned by the server contain forward slash character, and because of this JNDI escapes the whole name with double quotes: NamingEnumeration<SearchResult> results = dirContext.search(queryRoot, queryFilter, controls); for (SearchResult result : Collections.list(results)) { String objectName = result.getName(); System.out.println(objectName); } If one of the objects in the

Escape characters contained by bash variable in regex pattern

流过昼夜 提交于 2019-12-05 16:42:16
In my bash script, i am trying to execute following Linux command: sed -i "/$data_line/ d" $data_dir $data_line is entered by user and it may conatain special characters that could brake regex. How can i escape all of the possible special characters in $data_line before i execute sed command? You might be able to use this technique to protect the selector. The lines marked with " ***** " below are the significant lines. The others are mostly for testing and demonstration. The key is to use a character that doesn't appear in the user input to delimit the selector address. data_line='.*/ s/GOLD

Bash escaping spaces in filename, in variable

旧巷老猫 提交于 2019-12-05 16:41:38
I'm quite new to Bash so this might be something trivial, but I'm just not getting it. I'm trying to escape the spaces inside filenames. Have a look. Note that this is a 'working example' - I get that interleaving files with blank pages might be accomplished easier, but I'm here about the space. #! /bin/sh first=true i=combined.pdf o=combined2.pdf for f in test/*.pdf do if $first; then first=false ifile=\"$f\" else ifile=$i\ \"$f\" fi pdftk $ifile blank.pdf cat output $o t=$i i=$o o=$t break done Say I have a file called my file.pdf (with a space). I want the ifile variable to contain the

PHP: serializing and unserializing string containing escaped characters

…衆ロ難τιáo~ 提交于 2019-12-05 16:23:38
How do I correctly serialize and unserialize a string containing escaped characters? Given: $data = "\'test\'"; $out= serialize($data); print_r($out); // -> s:8:"\'test\'"; The problem here is, that the string length is not accepted by unserialize: $out = 's:8:"\'test\'"'; var_dump(unserialize($out)); // -> bool(false) But if I change the string length to 6 (ignoring the escape chars): $out = 's:6:"\'test\'"'; var_dump(unserialize($out)); // -> string(6) "'test'" It unserializes correctly. What would be a good way of handling this problem? Your test cases don't match, you're wrapping the

How to escape only certain characters

折月煮酒 提交于 2019-12-05 16:12:52
php function preg_quote escapes these characters . \ + * ? [ ^ ] $ ( ) { } = ! < > | : - Could you please suggest what I could use to escape these characters: + - && || ! ( ) { } [ ] ^ " ~ * ? : / Edited (as requested by "on hold"): I'm implementing a Solr search and it says: Solr gives the following characters special meaning when they appear in a query: + - && || ! ( ) { } [ ] ^ " ~ * ? : / To make Solr interpret any of these characters literally, rather as a special character, precede the character with a backslash character . This may help you: <?php $subject = "+ - && || ! ( ) { } [ ] ^ \