escaping

Do I need to escape characters in this MATLAB string?

I would like to call the following bash command in MATLAB: grep "Up to" ~/test_linux/vision1.1/log | awk '{print $7}' I use system() in MATLAB, but it turns out to have errors: >> [status string]=system('grep "Up to" ~/test_linux/vision1.1/log | awk '{print $7}' '); ??? [status string]=system('grep "Up to" ~/test_linux/vision1.1...

How do you escape Ruby string interpolation?

Given this code: has_many :foos, :finder_sql = <<-SQL select * from foos where bars = #{id} SQL The #{id} part is being prematurely interpolated. How do I escape it? Thanks. ...

Remove escaped quotes from Wordpress posts

In my content I'm giving my <h3> tags id's for the sake of direct linking. This is how it looks in the post editor: <h3 id="h3-title">H3 Title</h3> So that I can directly link to it like this: <a href="http://example.com/page#h3-title"&gt;H3 Title</a> However, the double quotes are getting escaped somehow, with the html output on...

PHP what happens when a string is double times mysqli_real_escape_string

I'm using mysqli. When I echo mysqli_real_escape_string($db,mysqli_real_escape_string($db,'"')); which one of those will be the output: 1. \" 2. \\\" ? Is there a safe way to check whether a string has been already escaped? Unfortunately, I cannot test at present as I cannot access MySQL for 24 hours. ...

Function to check if a string is backslashed for mysql

Since there is no function to check whether a string is escaped before entering it to the db, how can I do this with regex? $string = 'some" string'; if(!preg_match('//',$string)) { $string = mysqli_real_escape_string($string); } php manual: mysqli_real_escape_string backslashes characters encoded NUL (ASCII 0), \n, \r, \, ', ...

How to make XML get escaped in HTMLLayout of logback?

I'm using logback (with slf4j) to do the logging, and I've got many XML content to be logged in both text files and HTML files (with HTMLLayout). However, logback just inserts the raw XML in the <TD> tags for the HTMLLayout, without any escaping or <pre> processing. Here is the snippet of my logback.xml: <appender name="ALL" class="ch....

Built in method to get C-style escaped sequence for a string

Is there a built method in .Net for C-style escaping of strings? For example, I have to convert a string which contains quotes like "hello", and write it as an escaped string \"hello\". Actually, to be more precise: string original = "\"hello\""; should be converted to string what_i_need = "\\\"hello\\\""; I could have probably...

Escaping sed strings correctly

I have a regex and replacement pattern that have both been tested in Notepad++ on my input data and work correctly. When I put them into a sed expression, however, nothing gets matched. Here is the sed command: # SEARCH = ([a-zA-Z0-9.]+) [0-9] (.*) # REPLACE = \2 (\1) sed -e 's/\([a-zA-Z0-9.]+\) [0-9] \(.*\)/\2 \(\1\)/g' Here is...

Why shouldn't `&apos;` be used to escape single quotes?

As stated in, When did single quotes in HTML become so popular? and Jquery embedded quote in attribute, the Wikipedia entry on HTML says the following: The single-quote character ('), when used to quote an attribute value, must also be escaped as &#x27; or &#39; (should NOT be escaped as &apos; except in XHTML documents) when it appe...

Decode HTML entities in Python string?

I'm trying to work out if there is a better way to achieve the following: from lxml import html from BeautifulSoup import BeautifulSoup soup = BeautifulSoup("<p>&pound;682m</p>") text = soup.find("p").string print text >>> &pound;682m print html.fromstring(text).text >>> £682m So I'm trying to produce the same string that lxml retu...

Add backslash to String in Objective-c

I have a problem identical to this problem here. I even want to encode the same infromation as him (it's a date/time for asp.net)... When ever I try to add a backslash i get two backslashes since I used \. Everyone in the thread above has claimed that this is a problem with NSLog and that NSString does tread \\ as a \. I have checked ...

PHP - Execute an external command, but by passing an array, one for programme name, then arg1, then arg2, etc...

I have a PHP script that needs to execute programmes that will work on files that have spaces in the names. Most PHP functions for executing external commands (e.g. exec()) take an 1 string argument for the command line to execute. However then you have to do things like escapeshellarg() to make your input safe. Is there some way to exe...

How to properly escape output (for XHTML) in mako?

Despite offering a nice way to escape output using filters, none of them do the right thing. Taking the string: x=u"&\u0092" The filters do the following: x Turns the & into an entity but not the \u0092 (valid XML but not XHTML) h Exactly the same u Escapes both, but obviously uses url escaping ent...

negative lookbefore for a blackslash in ruby 1.9

I want to match every '[' or ']' that's not preceded by a backslash in ruby 1.9 I tried: /?<!\134[\[\]]/ and /?<!\\\\[\[\]]/ but I get a 'target of repeat operator not specified' ...

MSBuild - Writing Escape Characters to Files

I've got a very similar scenario to the one described in this post. It describes how to load the contents of a file that contains properties & items, making sure they're resolved as part of the process. I'm doing the same thing except writing the contents away to another text file (generally .ini file). In short I'd start by importing a...

Regex Quoted String with Escaped Quotes in C#

I'm trying to find all of the quoted text on a single line. Example: "Some Text", and "Some more Text" and "Even more text about \"this text\"" I need to get: "Some Text" "Some more Text" "Even more text about \"this text\"" \"[^\"\r]*\" gives me everything except for the last one, because of the escaped quotes. I have read abo...

Escaping html in Java

How do I make sure I don't escape something twice? I've heard that its good practice to escape values as you receive them from a form, and also escape when you output. That way you have two chances to catch something. ...

When should I HTML-escape data and when should I URL-escape data?

When should I HTML-escape data in my code and when should I URL-escape? I am confused about which one when to use... For example, given a element which asks for an URL: <input type="text" value="DATA" name="URL"> Should I HTML-Escape DATA here or URL-escape it here? And what about an element: <a href="URL" title="URL">NAME</a> ...

How can escaping be used to prevent XSS attacks?

To prevent XSS attacks, output escaping has been enabled; The above is from symfony,but I don't understand. ...

Java: how to get a File from an escaped URL?

I'm receiving an URL that locates a local file (the fact that I receive an URL is not in my control). The URL is escaped validly as defined in RFC2396. How can I transform this to a Java File object? Funnily enough, the URL getFile() method returns a String, not a File. I've created a directory called "/tmp/some dir" (with a spacing ...