escaping

How to handle escape sequences in string literals in ANTLR 3?

I've been looking through the ANTLR v3 documentation (and my trusty copy of "The Definitive ANTLR reference"), and I can't seem to find a clean way to implement escape sequences in string literals (I'm currently using the Java target). I had hoped to be able to do something like: fragment ESCAPE_SEQUENCE : '\\' '\'' { setText("'")...

How can one put a "[" after "\item" in LaTeX?

The following latex does not compile because of the "[" after the "\item". I presume it is because LaTeX expects a "]" as per the "\item[option]" syntax. However, I just want to insert the "[" character into the text as the first character of the enumerated item. \documentclass[oneside,12pt]{article} \begin{document} \begin{enumerate}...

Do you only run htmlspecialchars() on output or is there other functionality you also do?

When outputting user input, do you only use htmlspecialchars() or are there are functions/actions/methods you also run? I'm looking for something that will also deal with XSS. I'm wondering if I should write a function that escapes user input on output or just use htmlspecialchars(). I'm looking for the generic cases, not the specific c...

How to ignore escape sequences stored in PowerShell string variable?

In my PowerShell script, I'm running Select-String over a number of files, looking for a string passed into it via a variable ($id): foreach ($file in (ls "path\to\files")) { $found = $false $found = Select-String -Path $file $id -Quiet if ($found) { break } } Unfortunately, the $id variable sometimes things li...

How to escape extended pathname expansion patterns in quoted expressions?

In addition to the basic *, ? and [...] patterns, the Bash shell provides extended pattern matching operators like !(pattern-list) ("match all except one of the given patterns"). The extglob shell option needs to be set to use them. An example: ~$ mkdir test ; cd test ; touch file1 file2 file3 ~/test$ echo * file1 file2 file3 ~/test$ sh...

What escaping or purification is needed for an email subject?

Sites like Facebook have the user's name in the subject line that sent you a message. Because of this, what escaping would you do on user entered values in a message subject? Or would you just not allow anything other than a-z, 0-9, period, comma and single quotes? ...

XML Entity for "/" ?

So I'm writing some XML generating code, and found that the following attribute value was screwing up the XML formatting: "Jim/Bob" So I looked into the XML Entities used as escape sequences and every list I saw did not include one for the forward slash. Am I missing something obvious here? Seems like the sort of thing you'd want to ...

Escaping a character in TeX equation?

I want to use a variable name containing dash in TeX equation. However, dash gets interpreted as minus sign. Anyone any idea of how to escape the character? ...

Escape a period character in an SQL query

EDIT: Just realised that the reason for the additional results is down to another line in the query! Don't think I have enough rep to close this question. I'm editing some existing SQL code which is searching a Lotus Notes DB. I have this line: @Contains(Title; "blah blah 1.5") and I want to return only those records which contain e...

Displaying a Downward Triangle in VB.NET ▼ (U+25BC)

Hey, I'm trying to figure out how to display the ▼ character properly in a .NET winform application. I am creating a custom control, and for the button, I want this character to appear. I am able to set the text to this character, but it appears as a blank square. Any ideas on what I need to do to make this character appear properl...

escaping characters for substitution into a PDF

Can anyone tell me the set of control characters for a PDF file, and how to escape them? I have a (non-deflated (inflated?)) PDF document that I would like to edit the text in, but I'm afraid of accidentally making some control sequence using parentheses and stuff. Thanks. ...

Escaping Double Quotes in Batch Script

How would I go about replacing all of the double quotes in my batch file's parameters with escaped double quotes? This is my current batch file, which expands all of its command line parameters inside the string: @echo off call bash --verbose -c "g++-linux-4.1 %*" It then uses that string to make a call to Cygwin's bash, executing a L...

How to escape strings in MSSQL using PHP?

I'm looking for the alternative of mysql_real_escape_string() for MSSQL. Is addslashes() my best option or there is another alternative function that can be used? Edit: Alternative for mysql_error() would also be useful. ...

How do you get your Fulltext boolean search to pick up the term C++ ?

So, I need to find out how to do a fulltext boolean search on a MySQL database to return a record containg the term "C++". I have my SQL search string as: SELECT * FROM mytable WHERE MATCH (field1, field2, field3) AGAINST ("C++" IN BOOLEAN MODE) Although all of my fields contain the string C++, it is never returned in the search resu...

using ' in strings in delphi

in delphi a string in contained within a pair of 's but i need to use ' in my string.. and when i use one it brings a end to the entire string identification... 'inside string ' but this bit is outside' inside again' and the end is there some symbol that removes the coding affect of the next character? ...

XmlWriter only escaping one kind of quote

Here's some C# code: var sb = new StringBuilder(); var w = XmlWriter.Create(sb); w.WriteStartElement("hello"); w.WriteAttributeString("target", "world ' \" !"); w.WriteEndElement(); w.Flush(); // then look at sb.ToString() I'm getting a string that looks like: <?xml version="1.0" encoding="utf-16"?><hello target="world ' &quot; !" /...

innerHTML and C%23 (C#) in anchor hrefs - Firefox

If you set the innerHTML of a <div> to innerHTML = '<a href="Something/C%23">C#</a><br />'; What seems to actually get 'rendered' is: <div> <a href="Something/C#">C#</a><br /> </div> What is the proper way to escape this so the link will stay "Something/C%23" ? UPDATE: I noticed a weird little thing here. If you use a function to b...

href's javascript single and double quote problem

I am having problem with escaping the single and double quotes inside the hrefs javascript function - I have this javascript code inside href - its like - <a href = "javascript:myFunc("fileDir/fileName.doc" , true)"> click this </a> Now, since double quotes inside double quote is not valid - I need to escape the inner double quote...

decodeURIComponent vs unescape, what is wrong with unescape ?

In answering another question I became aware that my Javascript/DOM knowledge had become a bit out of date in that I am still using escape/unescape to encode the contents of URL components whereas it appears I should now be using encodeURIComponent/decodeURIComponent instead. What I want to know is what is wrong with escape/unescape ? T...

Best way to escape strings for sql inserts?

What is the best way to escape strings for sql inserts, updates? I want to allow special characters including ' and ". Is the best way to search and replace each string before I use it in an insert statement? Thanks Duplicate of: http://stackoverflow.com/questions/568995/best-way-to-defend-against-mysql-injection-and-cross-site-scrip...