escaping

Escape doube and single backslashes in a string in Ruby

Hello. I'm trying to access a network path in my ruby script on a windows platform in a format like this. \\servername\some windows share\folder 1\folder2\ Now If I try to use this as a path, it won't work. Single backslashes are not properly escaped for this script. path = "\\servername\some windows share\folder 1\folder2\" d = Dir...

Sanitizing user input before adding it to the DOM in Javascript

I'm writing the JS for a chat application I'm working on in my free time, and I need to have HTML identifiers that change according to user submitted data. This is usually something conceptually shaky enough that I would not even attempt it, but I don't see myself having much of a choice this time. What I need to do then is to escape the...

Flex actionscript datatable column names are encoded - how to decode?

Hi, I am returning a .NET datatable to Flex Actionscript via a web service. Once I have the datatable then I want to grab the column names. The following code outputs my column names: for each (var tcolumn:Object in datatable.Columns){ trace('Column:'+tcolumn); } This works ok, but the column names are somehow encoded, so a colum...

MySQL escape string help

I have a pretty large insert statement something like INSERT INTO multimedia (filename, regex, flag) VALUES (('adsfavr.jpg', '<div id="title">', 0), (...), (...)); How do I prepare the query for MySQL.It's too long to do it manually. It includes double quotes so I can't use the php function mysql_real_escape_string() ...

mysQL Query help regarding find text

Hello, I need to get all rows in which eventname field contains this text (including single quote) 's Birthday I tried this but it is giving error: select * from fab_scheduler where eventname like '%\'s Birthday%' How do i construct such query? Thanks ...

Safely escaping and reading back a file path in ruby

I need to save a few informations about some files. Nothing too fancy so I thought I would go with a simple one line per item text file. Something like this : # write io.print "%i %s %s\n" % [File.mtime(fname), fname, Digest::SHA1.file(fname).hexdigest] # read io.each do |line| mtime, name, hash = line.scanf "%i %s %s" end Of course...

How to "escape" a whole String - an SQL query

When I add a relative path to an SQL query as a String all the \ get removed. I am trying to add the String ("pics\\"+onlyFile) and as you can see I have escaped the \ character so I don't understand why it is being removed. onlyFile is a variable containing a file name. The value of the "src" variable (the one I am discussing) just be...

Android SAX parser not getting full text from between tags

I've created my own DefaultHandler to parse rss feeds and for most feeds it's working fine, however, for ESPN, it is cutting off part of the article url due to the way ESPN formats it's urls. An example of a full article url from ESPN.. http://sports.espn.go.com/nba/news/story?id=5189101&amp;amp;campaign=rss&amp;amp;source=ESPNHeadline...

Unescaping of data in JS

Say i got a variable, var s = "\"\\\"abc\\\"\""; which is unescaped to "\"abc\"" when i display in the browser. But i need it to be further unescaped to the actual value "abc". ...

Command to escape a string in bash

I need a bash command that will convert a string to something that is escaped. Here's an example: echo "hello\world"|escape|someprog Where the escape command makes "hello\world" into "hello\\world". Then, someprog can use "hello\world" as it expects. Of course, this is a simplified example of what I will really be doing. ...

c# winforms events restore textbox contents on escape

Using c# in 2008 Express. I have a textbox containing a path. I append a "\" at the end on Leave Event. If the user presses 'Escape' key I want the old contents to be restored. When I type over all the text and press 'Escape' I hear a thump and the old text isn't restored. Here what I have so far ... public string _path; public ...

Escaping escape Characters

I'm trying to mimic the json_encode bitmask flags implemented in PHP 5.3.0, here is the string I have: $s = addslashes('O\'Rei"lly'); // O\'Rei\"lly Doing json_encode($s, JSON_HEX_APOS | JSON_HEX_QUOT) outputs the following: "O\\\u0027Rei\\\u0022lly" And I'm currently doing this in PHP versions older than 5.3.0: str_replace(array(...

Literal ampersands in System.Uri query string

I'm working on a client app that uses a restful service to look up companies by name. It's important that I'm able to include literal ampersands in my queries since this character is quite common in company names. However whenever I pass %26 (the URI escaped ampersand character) to System.Uri, it converts it back to a regular ampersand ...

how to return clean javascript from a rails3 custom view helper?

Using Rails 3: In my update.js.erb file I found I was repeating a lot of stuff. So I tried to put it all into a helper. But I'm having trouble getting the helper to give back clean javascript. It puts in \&quot; everywhere instead of " Here's what I started with: <% if @list.show_today %> $("#show_today_check_<%= @list.id %>").rem...

How to handle a single quote in Oracle SQL

How do I insert a record in a column having varchar data type having single quote in it? Example: first name is ROBERT and last name is D'COSTA ...

escape exactly what in javascript

Hi all, Being a newbie in javascript I came to a situation where I need more information on escaping characters in a string. Basically I know that in order to escape " I need to replace it with \" but what I don't know is for which characters I need to escape a particular string for. Is there a list of these "characters to escape"? or...

How do you escape double quotes inside a SQL fulltext 'contains' function?

How do you escape a double quote character inside a MS SQL 'contains' function? SELECT decision FROM table WHERE CONTAINS(decision, '34" AND wide') Normally contains() expects double quotes to surround an exact phrase to match, but I want to search for an actual double quote character. I've tried escaping it with \, `, and even anoth...

How do I escape reserved words used as column names? MySQL/Create Table

I am generating tables from classes in .NET and one problem is a class may have a field name key which is a reserved MySQL keyword. How do I escape it in a create table statement? (Note: The other problem below is text must be a fixed size to be indexed/unique) create table if not exists misc_info ( id INTEGER PRIMARY KEY AUTO_INCREMENT...

PHP keeps escaping my form's input (adding \ behind my ')

So basically when I type something with an apostrophe, such as John's bike it will echo John\'s bike. The code below: <?php $searchname = $_POST["name"] ; echo "$searchname"; My form uses the POST method. Is there any way to stop this? Also to make input case insensitive how would I go about in this segment? $searchsport = $_POST['s...

How I can put " within an HTML attribute value

I wish to have the following: <span title="This is a "good" title.">Catch me in the rice.</span> It is obvious that this is not rendered well by the browsers. Please provide me with information of what escape sequence or encoding like " I must use? ...