escaping

How do I get some string values from Pylons controller be assigned to JavaScript variables with Mako?

I'm developing under Pylons using Mako templates. The problem is that I need to assign a string from some attribute of tmpl_context to a JavaScript variable in a page body. The additional problem is that this string can be quite arbitrary, ie can contain such characters like ", ', <, >, etc... Is there a common way to do such assignment?...

How to escape XML attribute values, and when do I need to?

I tried writing some XML that has a line like: <node attr="{foo}"/> and loading it in C#, and getting: System.Xml.XmlException: Name cannot begin with the '{' character, hexadecimal value 0x7B. Line 2, position 14. I tried escaping with &#x7b;, but that just gives: System.Xml.XmlException: Name cannot begin with the '&' character,...

need to selectively escape html entities (&)

I'm scraping a html page, then using xml.dom.minidom.parseString() to create a dom object. however, the html page has a '&'. I can use cgi.escape to convert this into &amp; but it also converts all my html <> tags into &lt;&gt; which makes parseString() unhappy. how do i go about this? i would rather not just hack it and straight rep...

In what context are angle brackets escaped with backslashes?

Hello, a bit of unusual question - in what context are angle brackets escaped with backslashes? I am sending an XML document (as a string xsd type) through a web service, which saves it to database, but there I see all XML's angle brackets escaped with a backslash, so I am wondering where exactly (Java XML creation using DocumentBuilder...

Display unescaped HTML String in Django Admin change list

Hey Guys! I am currently facing a serious problem. I use the standard django admin interface incl. change list to display one of my models. The model has got a field, which includes a link (e.g. in database: link). What I want now is that this string is rendered unescaped and displayed as link. I already tried the following in "change_...

Remove a bunch of escaped quotes from MYSQL.

I have an odd one - I am porting some data from one CMS to another. Both run on LAMP. In the old CMS, the data was stored, with slashes in the DB. Examples: Hi. Thanks for looking. It\'s \"awesome\". That correctly displays when output by the old CMS as: Hi. Thanks for looking. It's "awesome". But in the new CMS, they same text i...

In PHP do i need to escape backslashes?

I think this may be a stupid question, but I am quite confused whether I need to escape backslash in PHP. echo 'Application\Models\User'; prints Application\Models\User echo 'Application\\Models\\User'; same output echo 'Application\Model\'User'; gives Application\Model'User So it's a escape character, shouldn't I need to escape it (\...

How do I escape a character in XSLT

I have an XSLT that transforms a XML to PLSQL I need to escape the character: > (greater than) ex: P_C710_INT_PROFILE_ID => I tried using &gt; and putting the character in xsl:text with no luck Any ideas? Thanks ...

How do you do a backspace escape character in Android?

Hi guys, I have a textView with some text in it. I want to delete the last 4 characters and then add on some more text. I tried doing this. textViewObject.append("\b\b\b\b new text that I am adding"); But instead of the \b doing a backspace, they show up as little squares in the textfield. Can anyone help me out here? ...

Struts2 escaping select values

I have text in a option (using a select tag) that has multiple spaces. These spaces are then converted into one space. I then tried to escape the spaces with &nbsp; but it then converts it to: which is not what I want. Is there anyway to disable escaping in Strut2 or have it always escape spaces for me for select tags? There is a ...

Escaping in test comparisons

In the following, I would like check if a given variable name is set: $ set hello $ echo $1 hello $ echo $hello $ [[ -z \$$1 ]] && echo true || echo false false Since $hello is unset, I would expect the test to return true. What's wrong here? I would assume I am escaping the dollar incorrectly. TYIA ...

How can I insert the greater- and less-than characters into an XML file modified by WiX during install?

I'm using WiX to author a Windows Installation database for my application. I've got an XML file that is installed along with my app, which needs to be filled with information obtained during installation. The WiXUtilExtension tags util:XmlFile and util:XmlConfig are great ways to do this, in principle, but they don't quite solve my prob...

Escape string for use in Javascript regex

I am trying to build a javascript regex based on user input: function FindString(input) { var reg = new RegExp('' + input + ''); // [snip] perform search } But the regex will not work correctly when the user input contains a ? or * because they are interpreted as regex specials. In fact, if the user puts an unbalanced ( or [ ...

SQL LIKE Command trouble searching for '

Hi I am facing a problem with the like command in SQL, I want to search for special characters within a column . The special characters are a single quotation mark ' and { and }.. I have tried placing these special characters under [] but still it doesn't work for ' I have also used the except option but that was also of no help.. Wa...

Is anyone storing raw SVG data inside mongodb?

I'm working on a project where I'm looking to store raw svg data inside my mongodb. Right now, it appears a bit goofy because I need to escape the svg string like so: { "_id" : ObjectId("4c61e60d4d02da615f175b6e"), "name" : "Triangle", "svg-data" : "<?xml version=\"1.0\" encoding=\"utf-8\"?> <!-- Generator: Adobe Illustrator 14.0.0, SV...

xslt unescape twice (e.g. &amp;amp; to become &)

I am trying to transform some xml, which was returned by the Twitter Search api. It looks like the content element contains text that is escaped twice, Inception style. When I use the following in my XSL stylesheet it only unescapes it once: <xsl:value-of select="atom:content" disable-output-escaping="yes" /> How do I perform the seco...

PHP: How should I escape a string that will be going into a Javascript String?

How should I escape a string that will be going into a Javascript String? URLEncode(X)? str_replace("'","\'",X)? ...

Quoting and escaping text strings advice

I am mainly C++ programmer who returns to PHP seasonly. Every time I return I spend time to get used to echo/print correct JavaScript/HTML/CSS regarding the single quote and double quote ...etc. I need an advice in the form of a set of rules to follow for good escaping practice. Edit This is a small example for my bad working code tha...

KO3/Kohana3: How do we escape quotes (double and single) before saving to db with ORM using values()?

Hello everyone! I allow users to submit a question, and they should be able to have single quotes in their title. Currently, if a title contains a single quote, it will submit properly. $question->values($post_data); $question->save(); Any ideas on how I can set Kohana to escape that single quote / escape my information automatically? ...

How can I replace certain characters with their escaped variants using XSLT?

I'm trying to develop an XSLT stylesheet which transforms a given DocBook document to a file which can be fed to the lout document formatting system (which then generates PostScript output). Doing so requires that I replace a few characters in the text of DocBook elements because they have a special meaning to lout. In particular, the c...