escaping

Escaping reserved words

痞子三分冷 提交于 2019-12-07 18:02:15
问题 Sitecore provides a way of escaping words within a Sitecore query that contain characters that they don't like. Such characters include hyphens and spaces. In the interest of simplifying my life, I wrote a simple helper function that would escape every part of a Sitecore query, and it worked fine for a while: public static string EscapePath(string path){ return Regex.Replace(path, @"([^/]+)", "#$1#").Replace("#*#", "*"); } (the Replace("#*#","*") is in there because Sitecore doesn't like it

Angularjs - equal sign in $http post data

谁都会走 提交于 2019-12-07 17:31:53
问题 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

How do i solve this error? Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead [closed]

↘锁芯ラ 提交于 2019-12-07 17:31:30
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I get stuck on the following: Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead. in /home/xtremeso/public_html/mp3/includes/class/_class_mysql.php on line 116 function safesql( $source ) { if ($this->db_id) return mysqli_real_escape_string ($this->db_id,

Print stdout in Python without shell escape sequences

强颜欢笑 提交于 2019-12-07 16:42:58
问题 I'm using sh to run git commands inside a Python script. In [1]: from sh import git In [2]: s = git("log", "-1", pretty="format:%h %s") In [3]: print s 4f14a66 basic debug page This seems to work as expected. However, using this in a Django template gives [?1h= 4f14a66 basic debug page[m [K[?1l> . I tried to see what characters were in this string using repr() , to no avail: In [4]: print repr(s) 4f14a66 basic debug page It turns out commands in sh return a RunningCommand that has a .stdout

Put $$ in dollar-quoted string in PostgreSQL

℡╲_俬逩灬. 提交于 2019-12-07 14:33:44
问题 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

Custom replace for json encoding not outputting double quotes as expected

≯℡__Kan透↙ 提交于 2019-12-07 14:22:41
问题 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", " ")

Twig and autoescaping

一个人想着一个人 提交于 2019-12-07 13:38:26
问题 I'm learning Symfony2. Currently, I'm trying to render a form label in a twig template. The label includes an html tag, that is not rendered correctly in my twig file. Here follows the piece of code where the form field is created: $builder->add('zipcode', 'integer', array( 'label' => '<abbr title="Zone Improvement Plan">CAP</abbr> code', )); In the twig file I render the field label as follows: {{ form_label(form.zipcode) }} I tried the raw, escape, e filters, but the results provided in my

C++ regex escaping punctional characters like “.”

拟墨画扇 提交于 2019-12-07 12:30:26
问题 Matching a "." in a string with the std::tr1::regex class makes me use a weird workaround. Why do I need to check for "\\\\." instead of "\\."? regex(".") // Matches everything (but "\n") as expected. regex("\\.") // Matches everything (but "\n"). regex("\\\\.") // Matches only ".". Can someone explain me why? It's really bothering me since I had my code written using boost::regex classes, which didn't need this syntax. Edit: Sorry, regex("\\\\.") seems to match nothing. Edit2: Some code void

How to escape special characters in sphinxQL fulltext search?

旧巷老猫 提交于 2019-12-07 12:00:30
in the sphinx changelog it says for 0.9.8: "added query escaping support to query language, and EscapeString() API call" can i assume, that there should be support for escaping special sphinx characters (@, !, -, ...) for sphinxQL, too? if so, maybe someone could point me to an example on this. i'm unable to find anything about it in the documentation or elsewhere on the net. how do you do fulltext search (using spinxQL), if the search-phrase contains one of the special characters? i don't like the idea very much to "mask" them during indexing. thanks! There are corresponding functions

Bash escaping spaces in filename, in variable

随声附和 提交于 2019-12-07 11:59:06
问题 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