FAQ Database Discussion Community


XSLT convert xml block under a specific node to xml-escaped content of that node

xslt,escaping,xslt-2.0,cdata
Any ideas of how the following problem can be solved would be highly appreciated. INPUT: <p> <div> Original<br/>This is the original <b>acid</b>, a hydroxy monocarboxylic <span class="hl1">acid</span>. </div> </p> Desired Output: <p> <div> Original&lt;br/&gt;This is the original &lt;b&gt;acid&lt;/b&gt;, a hydroxy monocarboxylic &lt;span class=&quot;hl1&quot;&gt;acid&lt;/span&gt;. </div> </p> Attempt 1:...

How to remove a file beginning with a dash (in Unix like mode) [duplicate]

linux,unix,escaping,git-bash,rm
This question already has an answer here: How do I deal with a filename that starts with the hyphen (-) character? 4 answers I have accidentally created a file in GitBash (a Unix like environment) with the name - -l (I have absolutely no idea how I managed to...

Validate CSS in C#

css,escaping,xss
I have a web app which generates HTML-code. The user can enter some CSS-code, which is automatically inserted inside of a <style></style> tag. Now a malicious user could enter something like </style><script>maliciousFunction();</script><style> here. But if I simply escape the whole input, then also valid CSS is escaped (like braces for...

SQL Server query syntax with single quote

sql,sql-server,sql-server-2008,select,escaping
I have in my database KIA car model like CEE'D. How to write right syntax to get all car where model = CEE'D Now I am using semipart of model SELECT make, model FROM Cars WHERE model LIKE '%CEE%' But now I need to get by full model name. How...

combining tilde expansion with variable substitution in bash

bash,escaping,command-substitution,tilde-expansion,variable-subsitution
Say I'm running bash as root, and I want to chown the home directory of a user ada. Say also that ada is stored in a variable called $USER (because I'm doing this from a script). When I tried the following, chown -R $USER:$USER ~$USER the shell performed tilde expansion...

How to escape the '#' comment character within Ansible lineinfile module?

escaping,yaml,ansible
How can I escape characters in Ansible's lineinfile module? Here's the line I want to insert on the server: EMAIL='[email protected]' # Server notification email address enter only 1 address But when I try the following, Ansible refuses to parse it due to YAML errors: line="EMAIL='{{ email_address }}' # Server notification...

Regex catch string between strings

c#,regex,escaping
I created a small function to catch a string between strings. public static string[] _StringBetween(string sString, string sStart, string sEnd) { if (sStart == "" && sEnd == "") { return null; } string sPattern = sStart + "(.*?)" + sEnd; MatchCollection rgx = Regex.Matches(sString, sPattern); if (rgx.Count < 1)...

Use double quote then curly brace in powershell -Command

powershell,escaping,brackets
There are a couple questions related to this on here but they specifically address Write-Host. I want to run something like powershell.exe -Command "'example.exe' /f`"`{GUID`}`"" Only it fails with the error Missing closing '}' in statement block. At line:1 char:396 + $mypid=(get-process EXEName*).id;wait-process -id $mypid; & `C:\Users\User\AppData\Local\Temp\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}\Target.exe` /s /ig``{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX`}` /instance=1...

Javascript new line and double quote escape using java

java,javascript,regex,escaping
I have to call some Javascript functions from my Java code and some strings as parameter. The string may contain new line and double/single quote. So I want to escape the new line and double quote using java so that it can be passed smoothly to JS method? How to...

Java character escaping

java,escaping
While I was programming I found weird behavior for the java String. I am trying to parse a string as command with arguments: Below is a screenshot of the variables during debug. This is my code to read the command: public List<String> readCommand(Sender sender, String command) { boolean isInQuote =...

HTML code as text in Excel

excel,if-statement,escaping,excel-formula,worksheet-function
I have an Excel file that will be saved as an .csv file for importation into an email automation system. In a function I need to return a piece of HTML code as text. =IF(A2<0,"CHECKMARK CODE",A2) The "CHECKMARK CODE" needs to be replaced by: > < span style="font-size:16px">& #10003;</span>. For...

Escaping JavaScript snippet Inside PHP function in WordPress

javascript,php,wordpress,escaping
A function in one of php files of a WordPress-based website is cut off, I think due to an error in escaping multiple quotes and slashes. Here's the line of code in question: echo '<script>window.jQuery || document.write(\'<script src="' . get_template_directory_uri() . '/assets/js/vendor/jquery-1.11.0.min.js"><\/script>\')</script>' . "\n"; It generates the following html: <script>window.jQuery...

Add anchor to javascript array for use with handlebars.js

javascript,html,escaping,handlebars.js
I have a good number of arrays stored in a javascript variable. An example of one of my arrays is: { index: 6, template: 2, title: "Innovation Center", shortname: 'innov', projectActive: 'true', subtitle: "Construct", location: "alaska", x: 1304, y: 610, image1: "img/watt.jpg", image2: "img/image_2.jpg", bgImage: "img/bgImage.jpg", headline1: "Catapulting Ideas to...

xslt 1.0 escape apostrophe text with embedded html

json,xslt,escaping
I am trying to escape an apostrophe that appears in text which also contains embedded html tags. My XML looks like: <segment code="ASDF"> ... <text> <a href="asdf.aspx?lfn=GYPT_0&amp;u=0" >[ blah] </a> 08:57:11 02 OCT 2013<br /><b>blah</b> <br /> blah ...<br /><br /> About <a href="EEEERE.aspx?lfn=MAB_0&amp;u=0" ><b>breathing</b></a>: blah you "can't do" an...

JSON (schema) validation with escaped characters in patterns fails

json,validation,escaping
The following JSON object is valid: { "foo": "bar", "pattern": "^(\/?[-a-zA-Z0-9_.]+)+$" } Whereas this one is not: { "foo": "bar", "pattern": "^(\/?[-a-zA-Z0-9_.]+)+\.jpg$" } It's the escaped dot (\.), but I can't see why this should not be valid JSON. I need to include such patterns in my real JSON schemas....

CKEditor escape html

html,escaping,ckeditor,pre
I have CKEditor on post text where I want to insert html-code. Something like this: <pre> <code class="html"> <img src="path/to/img.jpg" /> </code> </pre> But when I save the text, CKEditor interprets img-tag as actual html-image and shows broken image. How I can prevent that and tell to escape html-code in...

Escape dot in jquery validate plugin

javascript,jquery,json,validation,escaping
I'm using a jquery validation plugin as below $( "#myform" ).validate({ rules: { user.email: { //the dot causes an error required: true, email: true } } }); I have a dot in the name of the user email input text field name and this causes an error. How do I...

Bash quotes disable escaping

linux,bash,command-line,escaping
I want to run some command, let's name it "test" from my bash script and put there some of params from bash variable. My script: #!/bin/bash -x PARAMS="-A 'Foo' -B 'Bar'" ./test $PARAMS I've got: + PARAMS='-A '\''Foo'\'' -B '\''Bar'\''' + ./test -A ''\''Foo'\''' -B ''\''Bar'\''' It's wrong! Another one...

Unterminated object when converting a String to JSON

java,android,json,escaping,jsonobject
I am working with Android Studio, andI have a string variable, called sResponse (below). According to the debugger, it holds the following value: { "responseData": { "emotion":"", "lastinput":{actionResult={"value":{"label":"green","key":"1"},"result":"success","action":"displayClickableList"}, "answer":"Sorry, I did not understand.", "link": { "href":"", "target":"" }, "extraData": { }, "responseSession": { "id":"c4a5ef257851a991eb32c69132c9", "transaction":"4" }, "responseDetails": "null", "responseStatus": "200",...

Expanding asterisk in bash

bash,parsing,escaping,globbing
I'm trying to run find, and exclude several directories listed in an array. I'm finding some weird behavior when it's expanding, though, which is causing me issues: ~/tmp> skipDirs=( "./dirB" "./dirC" ) ~/tmp> bars=$(find . -name "bar*" -not \( -path "${skipDirs[0]}/*" $(printf -- '-o -path "%s/\*" ' "${skipDirs[@]:1}") \) -prune);...

How to replace with percent character in cmd.exe?

windows,replace,cmd,escaping
In the Windows command prompt, I am trying to replace the space in set string=Hello World with the string %20. Naively trying to use the string literal %20 like this: set string=%string: =%20% results in HelloWorld20%. Trying to use the escape character ^ like this: set string=%string: =^%20% also results...

Escape parts of string with a character in c# using regex

c#,regex,string,escaping
I have a string such as this: /one/two/three-four/five six seven/eight/nine ten eleven-twelve I need to first replace dashes with spaces, and then be able to escape any grouping of words that have a space between them with a "#" symbol, so the above string should be: /one/two/#three four#/#five six seven#/eight/#nine...

JavaScript escape from multiple quotes

javascript,escaping
I'm basically trying to put this.name instead of "main" tag. Could not find a way to do it on javascript since quotes messes it up. Code: document.querySelector('button[name="main"]').classList.add('selected'); ...

Format a command in powershell including a comma, can't find the right way to escape

powershell,batch-file,escaping,powershell-v2.0,comma
I have a command that I need to run in a Powershell script, the command is : ".\pacli DELETEUSER DESTUSER='"[email protected]`,com"' sessionid=333" | invoke-expression The comma (,) in here :[email protected],com is not a mistake, and that's what is giving me the hard time. I tried to escape the comma with `...

How to escape an equals sign in param element's value attribute?

javascript,actionscript-3,flash,escaping,swf
I have an embed tag that will be used to store a SWF object. I've been following this documentation here https://helpx.adobe.com/flash/kb/pass-variables-swfs-flashvars.html I need to create a parameter with a name equal to FlashVars. I need to store an API token in the value attribute. The problem is there is an...

Bash - How to get string length exclude escape character

bash,shell,escaping
I wrote a function in my ~/.bashrc to draw a horizontal line based on current terminal width. p_blod=$(tput bold) #use p_orig to reset it p_red=$(tput setaf 1) #print red p_blue=$(tput setaf 21) #print blue p_yellow=$(tput setaf 11) #print yellow p_orig=$(tput sgr0) #print back original color vzone() { : "${3?"Usage :...

Escaping input for insertion into XQuery string

php,escaping,xquery,basex
Say I have the following code: let $search := "placeholder" ... ...functx:get-matches-and-non-matches($t,$search)... This code is stored like this in a file, gets loaded into a string (by PHP), placeholder gets replaced with user input, and then the code gets executed. Obviously, " needs to be escaped somehow. Is there any...

JavaScript Regex: Escape the string “c++”?

javascript,regex,escaping
I'm working on some regex for a input text field and have had some trouble escaping special characters such as "+" or "?". I've used these two questions for doing so and they work for a string such as c+ but if I enter c++ I get following error in...

regular expressions with escaping round brackets

php,regex,escaping,preg-match,brackets
I am trying to write the expresion that will accep fallowing phone numbers format: 508 736 756 505050505 +48 505 505 505 (+48) 505 505 505 ++48 505 505 505 (++48) 505 505 505 (23)692 36 99 23 692 36 99 I have wrote the fallowing expresion ^(([+]{0,2}?)?([+]{0,2}?)?([0-9 ]+)?)$ How...

escaping | in batch for loop

loops,batch-file,escaping
I have a loop for /f "usebackq" %%u in(...) do SET heel=!heel! ^^^| ooo if im appending variable that way im getting error ooo is not recognized as an internal or external command How can I escape | char? If im not appending that variable im not getting that error...

python sqlite3 CREATE TABLE escape using list as headings?

python,sqlite3,escaping
I am trying to use a list as headings in my sqlite3 table using this code: import sqlite3 as lite headers = ['Id', 'Name', 'Price'] con = lite.connect('test.sqlite3') with con: cur = con.cursor() cur.execute("CREATE TABLE Cars(? INT, ? TEXT, ? INT)", tuple(headers)) However I am getting this error: OperationalError: near...

C escape sequence \033[999D not working properly

c,escaping
I'm trying to use the escape sequence \033[999D as a brute-force way of moving the cursor to the top row in the console. When I run my program, rather than doing what I intend, it returns a left-pointing arrow and a [999D, on the same line that I was last...

Escape symbol '<%=' and '%>'

javascript,ruby-on-rails,ruby-on-rails-4,escaping,chart.js
How can I escape these characters so that I can print it in the view <%= %> I am using chart.js on the view and on it's javascript code it needs those characters: var appPerMonthTrendChart = new Chart(ctxAppPerMonth).Line(dataAppPerMonth, { responsive: true, datasetStrokeWidth : 3, multiTooltipTemplate: <%= datasetLabel %>: <%= value...

How to escape variables in C#?

c#,string,variables,escaping
I want to know if what wrong is with this peace of code? I mean how to escape to variables from strings (in C#)? (if I had correctly understood what escaping is.) int i; string s; for(i=0;i<10;i++) { s="\u00A"+i; Console.WriteLine(s); } (Actually I want the program to write a sereies...

Django custom widget displaying escaped html

python,html,django,templates,escaping
I wrote a widget for Django forms in order to have a bootstrap3 multiple checkbox directly in the template in order to reuse it in the future. So I wrote an app prettyforms which contains all basic files (__init__.py, views.py ...) and created a forms.py where I wrote the custom...

“stringByAddingPercentEncodingWithAllowedCharacters” replaces more characters than it should

swift,cocoa,escaping
Playing around with Swift I came across something I do not understand. The following code replaces not only the /% characters as intended, it also replaces the ä character: immport Foundation extension String{ func encode() -> String{ let customAllowedSet = NSCharacterSet(charactersInString:"/%").invertedSet return self.stringByAddingPercentEncodingWithAllowedCharacters(customAllowedSet)! } } let testStr = "Ein String...

Safely pass Make variable to shell commands

shell,make,escaping,quoting
Consider this Makefile: VAR1=oneword VAR2=two words VAR3=three" quoted "words test: printf '>%s< ' "$(VAR1)" "$(VAR2)" "$(VAR3)" @echo If I run it, I get $ make test printf '>%s< ' "oneword" "two words" "three" quoted "words" >oneword< >two words< >three< >quoted< >words< print but I would like to get the same...

How to escape single or double quote in JavaScript?

javascript,escaping
I am trying to replace quote (') with \' so as to escape escape quote or double quote in string <ul id="list"> </ul> <button id="sethrefbtn" onclick="setlink();">Set Link</button> function setlink(){ var data = { playerID : 102458, playername: "Real Madrid's cristiano Ronalado" } listring= "<li><a href='SearchServlet?q=" + data.playername.replace(/'/g, "\'"); + "&playerid="...

Write code (with special chars like \ or ") in variable

bash,sed,escaping
I have a script (init.sh) which create other scripts. So, in init.sh I want to have variables containing the other scripts. I use read -d to do that : read -d '' script <<"EOF" # Some code sed -i "/PARALLEL_MAKE = \"-j 16\"/c\PARALLEL_MAKE = \"-j $threads\"" conf/local.conf # Some code...

Variable escape in bat

variables,batch-file,escaping
I have a bat file,just like it: if "%HOME_PATH:nodejs=%"=="%HOME_PATH%" ( when my HOME_PATH include "C:\Program Files (x86)\WinRAR", () or some other character is not Allowed here! How can I do it?...

Escape double quotes within double quotes with Regex[JS]

javascript,regex,json,escaping
I have a JSON string: '{"place": {"address": "Main Street, \"The House\""}}'. Before parsing it with JSON.parse() I have to make sure that the double quotes within double quotes are escaped properly. I was trying to come up with the regex that would match "The House", but failed to so. Any...

jquery -div id match failing due to presence of \ in the id

jquery,html,escaping
$('#bannerAbc tr td .scroller div.checkbox[id="' + $('#hdnfieldstring').val().trim().split(',')[i] + '"]').each(function () { $(this)[0].className = $(this)[0].className + " checked"; }) hdnfieldstring has values like 'abc\xyz, edc\qaz' each of the value being div id. The above code works for id without \ in them, but does not work of the sample data i...

In C++, how can I cout a logo that features many special characters?

c++,escaping,cout
I have a logo that features many special characters, such as escape characters, and I want to print it to the terminal. How should I do this without the compiler throwing "unknown escape sequence" errors? Here is some example code (that features only one problematic character -- not, say, hundreds):...

Supress % (percent sign) escaping in a CMD file? (Redux)

batch-file,cmd,command,escaping
After researching, I think I know the answer to this: no. But just in case I am missing something: Is there a way to globally suppress % escaping in a CMD file? Something like: SETLOCAL NOESCAPE MYAPP.EXE "%41%42%43%44" So MYAPP.EXE sees the literal string: "%41%42%43%44" I know I can double...

JSON.parse with json_encode and html

javascript,php,html,json,escaping
I have got the following html string: $htmlString = '<div class="foo">bar</div>'; I would like to json_encode this string and parse this in a javascript variable, using the following code: JSON.parse('<?= json_encode($htmlString, JSON_HEX_QUOT | JSON_HEX_TAG); ?>') Unfortunaly, my javascript returns an error (Unexpected token f) because the double quote in the...

Can't escape a closing parenthesis in Java?

java,regex,escaping
I have a very long regular expression that seems to be having issues, but only when imported from a text file. I've narrowed it down to the following section (shown here as a literal String): "(?i)(?<!\\w)\\w{2,3}(?=\\))" As you can see, near the end, I am trying to escape a closing...

MySQLI- Allow the Forward Slash to be Used With Insert Statement

php,mysql,mysqli,escaping
I have a MySQL field ("imagelocation") that contains the relative pathname to an image. Essentially the construct: "DirectoryName/ImageName.png" The "/" is causing a problem. I get the error message: "Unknown column 'Analog' in 'field list'" (Analog is the name of the directory.) Prior to building the pathname, the following code...

Escaping colon “:” in Hibernate/Postgres/JSON

json,hibernate,postgresql,escaping
I am trying to build up an HQL query that uses the postgress json search capabilities. In straight SQL, the following works as expected: sb.append("select...<blah>, regexp_split_to_table(fe.meta::json->>'elementName', ',') ... I have tried every combination of escaping that "::json" I can find on the web. sb.append("select...<blash>, regexp_split_to_table(fe.meta\\:\\:json->>'elementName', ',') ... :\\: \\:: using...

Getting value without $_POST and escape html

php,html,oop,post,escaping
I've a form class I'm calling from display() method.Then display() method getting value of name,email,password etc by $_POST method.But I want to getting the name of value with out $_POST.And also want to escape html.Is it possible to get value with out $_POST then escape html. Like this formet classname::get('name');...

Escape symbols shown in “git log view” (C-x v l) in Emacs

git,logging,emacs,escaping
When doing C-x v l on a Git versioned file in Emacs, I get its recent history but with escape symbols ^[[... See http://screencast.com/t/x1YWh4GKZR. What's wrong in my config?...

How to use regex to match anything from A to B, where B is not preceeded by C

c#,asp.net,regex,escaping
I'm having a hard time with this one. First off, here is the difficult part of the string I'm matching against: "a \"b\" c" What I want to extract from this is the following: a \"b\" c Of course, this is just a substring from a larger string, but everything...

Symfony2 disable form label html escape

forms,symfony2,escaping,labels
I have a form label printed like this: {% set txt = 'Im OK with the <a href="#">terms and conditions</a>' %} {{ form_label(form.terms, txt) }} But obviously this will escape the html tag and will print something like this: <label>Im OK with the &lt;a href="#"&gt;terms and conditions&lt;/a&gt;</label> Is there a...

How do I escape colons in an attribute name with Python's ElementTree?

python,xml,escaping,python-2.6,elementtree
Background I am using ElementTree in Python version 2.6 to create an XML file (using data retrieved from a database). Code The following line of code is the problem area, as I keep getting a syntax error because of the colons within my attribute names. # Please ignore any errors...

Escape '@' in names

ruby-on-rails,ruby,escaping,activeresource
I use Rails 4.2.0 with ActiveResource to implement a webclient for server API. The problem I've faced is that server resources contains '@' and '@@' in attribute names. So these attributes can't be processed correctly by ActiveResource while creating ARes object. Example: server returns JSON data: {"@@artist"=> {"@id"=>"some_text_id", "@name"=>"Carman", "@publisher"=>"Carmen...

How to embed hex values in a lua string literal (i.e. \x equivalent)

string,lua,escaping,hex,string-literals
In various languages, you can embed hex values in a string literal by using the \x escape sequence: "hello \x77\x6f\x72\x6c\x64" How can I do the same thing in Lua 5.1?...

Query xml in SQL Server - escaping square brackets

sql-server,xml,xpath,escaping
I am trying to query XML in SQL Server but I am getting errors due to my data contains the [ and ]. My XML format (third party so I cannot change this format and get rid of the square brackets): <MyRootElement> <MyChildElement name="[Name1]"><MyChildElement> <MyChildElement name="[Name2]"><MyChildElement> <MyChildElement name="[Name3]"><MyChildElement> </MyRootElement> I...

Add an attribute to an object with different kind of accent in Angular

javascript,angularjs,encoding,character-encoding,escaping
my usecase is: I have a ng-model "myModel". I'm pulling the html for a form via ajax (because I have dynamic fields) and in it, the fields are described with: <input ng-model="myModel.myField" name="myField"> This works perfectly except when the name of the field has an accent in it (it is...

Python-like Byte Array String representation in C#

c#,escaping,bytearray,ascii
Here is the method I am using to get this string representation: public static string ByteArrayToString(byte[] ba, string prefix) { StringBuilder hex = new StringBuilder(ba.Length * 2); foreach (byte b in ba) { if (prefix != null) { hex.Append(prefix); } hex.AppendFormat("{0:x2}", b); } return hex.ToString(); } Here is a sample...

bash: Expand list of arguments and pass it to find - escaping/white spaces hell

linux,bash,shell,find,escaping
I want to check a folder for files and delete some of them. One condition is to keep all files of a certain type (e.g. .txt) and also keep all files with the names of the first search but with different extensions ([names of first search].). All other files in...

SOLVED: QT: Escape slash / in saving location on a mac

osx,qt,escaping
I have HTML input I am supposed to extract 2 Strings of, build a document title string of type <string 1> / <string 2, create a PDF from the source on the users mac desktop and name it as described. I do know that a slash in a document name...

Wrap Words in Square Bracket Instead of sglQuotedString or dblQuotedString

javascript,python,escaping,pyparsing
I'm using pyparsing to parse a boolean string query. So I will be sending a string that looks something like this: string = "'foo' AND 'bar' OR NOT 'foobar'" I'm using sqlQuotedString() but there will be times that the string being parsed will contain other types of punctuation like apostrophes...

Escaped asterisk (*) in list of characters outputs file in folder

bash,shell,escaping,asterisk
At the very beginning of my Bash script I'm passing a set of characters like this: #!/bin/bash set0="0 1 2 3 4 5 6 7 8 9" set1="° § + \" ç % & / ( ) = ? ' ^ ! £ $ - _ ; , : ....

How do I keep single quotes intact when returning the output of a Bash subshell to the OSX “defaults” utility?

osx,bash,shell,escaping,quotes
Context/Goal: I'm trying to write an array to a key in a .plist file via the OSX defaults utility. My goal is to rewrite the array with contents of my choosing, not to modify its existing contents. The new contents are the product of another command, and are supposed to...

Enable a single escape sequence in echo

bash,escaping,echo
In my bash script I need to echo a tab (this happens in a loop) echo -e "$first\t$last" Unfortunately, $last might contain some escape sequences, as \n, which should be preserved. Is there any way to enable only the tab escape sequence? I'd rather not decrease performance significantly since my...

Does the Struts2 tag escape HTML by default?

jsp,struts2,escaping,struts-tags,html-escape
Unless escapeHtml="false" is explicitly set, the <s:property> tag escapes HTML by default: <s:property value="someValue" /> <!-- the HTML contained in "someValue" will be escaped. --> Does <s:set> also behave this way ? <s:set var="myVariable" value="someValue" /> <!-- will the HTML contained in "someValue" be escaped ? --> ...

Escape tab character PostgreSQL

json,postgresql,escaping,plpgsql
I have got a varchar field and I am migrating this field to a JSON type field. Some of the data has got tabulator, and when trying to insert to the new JSON field it tells me this error: DETAIL: Character with value 0x09 must be escaped. I am trying...

React keeps escaping the amp character (&) in attributes

javascript,css,escaping,reactjs,react-jsx
I have a component with a data-icon attribute. The value of this attribute should be, for instance, &#xf00f so that css can render it via content: attr( data-icon );. However, whatever I try: React keeps escaping to &amp;. Even when I provide the proper unicode character \u0026#xf00f. Is there some...

Escaping apostrophies and other characters in text area

php,html,forms,escaping,textarea
So I have found that this form I have just falls apart and doesn't even submit the content up until the first apostrophe when someone types in an apostrophe to this text area. How do I go about escaping the contents so they make it into my MySQL table? Thanks!...

Underscore template not rendering variable with <%-

templates,escaping,underscore.js,underscore.js-templating
I have a simple template: <div class='welcome'>Welcome <%- first_name %>!</div> However my variable first_name is not rendered. This works fine: <div class='welcome'>Welcome <%= first_name %>!</div> and this correctly logs the variable: <div class='welcome'>Welcome <%- first_name %><% console.log(first_name);console.log(typeof(first_name)); %>!</div> which is of type string as expected. I couldn't find anyone with...

Escape html & non-ascii chars with javascript

javascript,html,string,escaping,non-ascii-chars
OK, so I need to replace all <, & and > plus all non-ascii characters with their html-entity counterparts. I've tried Underscore.string.escapeHTML but that didn't seem to touch the non-ascii chars. For example I need this: <div>föö bär</div> converted into this: &lt;div&gt;f&ouml;&ouml; b&auml;r&lt;/div&gt; Obviously auml and ouml are not enough....

Reading java file with escape characters for newline

java,escaping,bufferedreader,unicode-escapes
I have a Unicode file that needs to be exported to database(Vertica). The column delimiter is CTRL+B, record delimiter is newline(\n). Whenever there is a newline within a column value, CTRL+A is used as escape character. When I use BufferedReader.readLine() to read this file, the records with ID's 2 and...

How to escape apostrophe in php variable for select query

php,mysql,string,mysqli,escaping
i have tried escaping the qurey string and the $variable containing the apostrophe using the mysqli_real_escape_string the variable value is coming form the database. i am getting the following error. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the...

Strange error in batch file when handling a file path with Program Files (x86)

windows,batch-file,escaping,environment-variables
I am writing a batch script to remove quotes from the JAVA_HOME env variable and am getting an error only when JAVA_HOME is set with "Program Files (x86)" in the path. My JAVA_HOME variable is set to C:\Program Files (x86)\Java\jdk1.7.0_79(no quotes are in the value) set lastChar=%JAVA_HOME:~-1% set firstChar=%JAVA_HOME:~0,1% echo...

Ignore escaped double quote characters swift

regex,swift,escaping,nspredicate,nsregularexpression
I am trying to validate a phone number using NSPredicate and regex. The only problem is when setting the regex Swift thinks that I am trying to escape part of it due to the backslashes. How can I get around this? My code is as follows: let phoneRegEx = "^((\(?0\d{4}\)?\s?\d{3}\s?\d{3})|(\(?0\d{3}\)?\s?\d{3}\s?\d{4})|(\(?0\d{2}\)?\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3}))?$"...

Replace text without escaping in BeautifulSoup

python,html,escaping,beautifulsoup
I would like to wrap some words that are not already links with anchor links in BeautifulSoup. I use this to achieve it: from bs4 import BeautifulSoup import re text = ''' replace this string ''' soup = BeautifulSoup(text) pattern = 'replace' for txt in soup.findAll(text=True): if re.search(pattern,txt,re.I) and txt.parent.name...

ANSI escape characters in gprolog

prolog,escaping,iso-prolog
Trying to print bold and underlined text in prolog but can't write them write('\033[1mbold\033[0m') Makes this (expected) error: syntax error: \ expected in \constant\ sequence What's the correct way to do it with gprolog ? Maybe with format ?...

What are the possible levels of nested quotes in C#?

javascript,c#,asp.net,string,escaping
I am trying to directly write a Javascript variable assignment code on a ASP.NET web page. Response.Write("<script>itHtml = '"); Response.Write("<div id=\"pop_ctrl\">Select</div><ul id=\"demo_ul\">"); foreach (Article a in arts) { Response.Write("<li class=\"demo_li\"><a onclick=\"ShowArticleCard(" + a.Id + ",\'" + a.User + "\',\'" + a.DateString + "\'); return false\"><div>" + it.User + "</div>&nbsp;&nbsp;<div>" +...

Unicode escaped comments in Python

python,unicode,escaping,comments,lexical-analysis
I made a Java program that uses unicode escaped characters to break a multiline comment and hide some functionality. The program below prints "Hello Cruel World". I'm wondering if this is possible to do in Python (any version). If it is not possible, how is this prevented in the language?...

Which quotes to use in string literal nested in another string

javascript,escaping,quote
I have in jQuery a function to change the html-content in a div, but the problem is that there is an onclick-function in it. I do not know which quote tags to use. [q] = quote tag, that I do not know $("#container div").html("<div id='overlay' onclick='goFullscreen([q]video1[q])'></div>"); ...

How do i escape these ampersands in php?

php,json,escaping,steam,steam-web-api
So im currently writing something that uses the steam web api and im trying to get the steam market price via the web api like so: `$url = 'http://steamcommunity.com/market/priceoverview/?currency=3&appid=730&market_hash_name='.$itemInfo['market_hash_name'];` the $itemInfo['market_hash_name'] is something from another JSON i got from the api That should return something like this: http://steamcommunity.com/market/priceoverview/?currency=3&appid=730&market_hash_name=SCAR-20 | Contractor...

Escape character for Location of char in a string: R lang

regex,r,escaping
I'm trying to get the location of \ or / in a string. Below is the code I'm attempting: x <- "<span id=\"ref_12590587_l\">6,803.61</span>_l>" gregexpr("\\\", x) which(strsplit(x, "")[[1]]=="\") My problem is when I attempt these codes in Rstudio, I get a continue prompt, the REPL prompt becomes +. These codes work...

Raw string and regular expression in Python

python,regex,escaping,backslash,rawstring
I have some confusions regarding raw string in the following code: import re text2 = 'Today is 11/27/2012. PyCon starts 3/13/2013.' text2_re = re.sub(r'(\d+)/(\d+)/(\d+)', r'\3-\1-\2', text2) print (text2_re) #output: Today is 2012-11-27. PyCon starts 2013-3-13. print (r'(\d+)/(\d+)/(\d+)') #output: (\d+)/(\d+)/(\d+) As how I understand the raw string, without r, the \...

Differences between \W, \\W, [^a-zA-Z0-9_] in regular expression

java,regex,string,escaping
I am trying to find all characters, which is not letters(upper/lowercase), numbers, and underscore, and remove it. stringA.replaceAll("[^a-zA-Z0-9_]","") // works perfectly fine <br/><br /> However, the following code could not even compile in Java stringA.replaceAll("\W","") or stringA.replaceAll("[\W]","") or stringA.replaceAll("[\\W]","")<br /> If I use only "\\\W" rather than "\W", the above...

How to display HTML markup content from database record to browser properly in Struts 2?

html,struts2,escaping,html-escape
I have a simple text stored in the database record: Hello wrapped in an h1 tag. When I print this record in the JSP with the <s:property /> tag, it displays: <h1>Hello</h1> While I want it to be displayed like: Hello How can I get the interpreted value, instead of...

Replacing %uXXXX to the corresponding Unicode codepoint in Ruby

ruby,regex,unicode,escaping,gsub
I have filenames which contain %uXXXX substrings, where XXXX are hexadecimal numbers / digits, for example %u0151, etc. I got these filenames by applying URI.unescape, which was able to replace %XX substrings to the corresponding characters but %uXXXX substrings remained untouched. I would like to replace them with the corresponding...

Encode\escape string for .NET [duplicate]

.net,encoding,character-encoding,escaping
This question already has an answer here: Can I convert a C# string value to an escaped string literal 11 answers I have a string of assorted white-space: e.g. "\t\r " I need to display it in an error message, but just showing white-space isn't helpful. Is there a...

How to escape from hex to decimal

c,escaping,hex
I apologise if this is an obvious question. I've been searching online for an answer to this and cannot find one. This isn't relevant to my code per se, it's a curiosity on my part. I am looking at testing my function to read start and end bytes of a...

SQL-injection in PHP, how is it possible to send non-escaped quote to server?

php,mysql,escaping,sql-injection
This code seems to be unsafe: <form method='post'> <input type='text' name='x' style='width:1000px'> <input type='submit' value='Send'> </form> <?php if(isset($_POST['x'])) { require_once("db_connect.php"); $q = mysqli_query($dbc, "SELECT x FROM table where x = '". $_POST['x'] ."'"); while($r = mysqli_fetch_assoc($q)) echo $r['x']; } but when I sent malicious input, it did not work. So...

PHP implementation of javascript escape() and escape()

javascript,php,encoding,escaping
First of all I understand both JS escape() and unescape() are deprecated. Basically we have an ancient system which JS escape() the data before storing in DB, every time we need to unescape() the data on client side before we can display the actual data (I know it's stupid but...

Executing Python Script from C++ program in Windows XP

python,c++,escaping,shellexecute
I am attempting to execute a python script from a C++ program. The problem that I am having is that I am unable to execute my python script. If I take out the lpParameter value by setting it equal to NULL everything works fine, my program launches the python terminal...

How to escape backslash in // comment

c++,escaping,comments,preprocessor,clang++
I have a comment that ends with backslash. Somethink like ... // use \ .. Clang(++) warned me, that this is multi-line comment warning: multi-line // comment [-Wcomment] // use \ ^ So I try add some whitespace at the end, but didn't help. Can I escape backslash somehow?...

How do you escape a double-colon in a DOS batch file?

batch-file,escaping,dos
I need to run a command in a DOS batch file that contains a double colon AND set the output to a variable. Like this set /a TDR = C:\InCharge\CONSOLE\smarts\bin\dmctl -s SSA-SAM invoke SM_System::SM-System nameToAddr %SM_OBJ_InstanceName% I keep getting "Missing operator". I assume that is due to those double-colons. How...

escape a string in node js to insert it in a sqlite3 database

javascript,string,node.js,sqlite,escaping
I'm using the external module sqlite3 to write and read my db. I want to store a very large description in my db which can contains some particular character. How can I correctly escape the string?...

Convert escape characters in strings (like “\\n” - two characters) into ASCII character (newline)

python,escaping
My program got a string from the command line arguments, that contains many escapes characters. ./myprog.py "\x41\x42\n" When I print "sys.argv[1]". I got on the screen: \x41\x42\n Is there a simple way to do that the program print instead: AB[newline] ...

How do I escape spaces in a path with Applescript?

path,escaping,applescript,filenames,space
I've written a script so I can quickly get a link to files and folders on my server. The problem is that the string I get does not escape spaces. Can someone tell me how to escape the spaces for '%20' ? tell application "Finder" set sel to (the POSIX...

PHP character escape sequence does not work

php,eclipse,web,escaping,wampserver
I am an extreme web programming beginner who is just starting to learn PHP with some knowledge of HTML and JavaScript. I use WAMP Server as my web server and Eclipse PDT as my IDE. I created a .php file in Eclipse. I just want to run a simple code...

Substitution of variable into link with many interior quotes - how to escape correctly

javascript,variables,escaping,quotes
I am setting up a link to Adobe's Aviary web app, which requires input in the following format: <a href="#" onclick="return launchEditor('editableimage1', 'http://www.mywebsite.com/IMAGE.jpg');">Edit!</a> I need to substitute a variable name for the IMAGE.jpg part of this, and I have tried to do this using the following code. Since the visual...

NSURL breaking port string with colon

ios,escaping,nsurl
I'm trying to add a base url for my networking code, the problem is that this URL gets broken when passing to the URLWithString:relativeToURL: method. This URL has the port i'm using, however, after calling the described, the URL is wrong, not including my current port number. I think this...

What exact code-point conversion does string literal prefix “r” imply (Python 3.4)?

python,string,python-3.x,unicode,escaping
What Unicode code-point conversion does the stringprefix "r" (or "R") actually perform on string literals in Python 3 (literals/files parsed as UTF-8)? I am using Python 3.4 on Windows 7. I want to to parse this "evil" path on Windows: >>> a = 'c:\a\b\f\v' >>> a 'c:\x07\x08\x0c\x0b' >>> a.decode(encoding='utf-8') b'c:\x07\x08\x0c\x0b'...

URI escape / unescape from Javascript to Perl

javascript,perl,escaping,uri
I have an URL that javascript reads from an user input. Here is a part of javascript code: document.getElementById("Snd_Cont_AddrLnk_BG").value=encodeURI(document.getElementById("Con_AddresWeb_BG").value.toString()); Then I post the value of the string through CGI to a Perl Script (here is a part of perl code): #!/usr/bin/perl -w ## ## use strict; use CGI; use CGI::Carp...