escaping

How to echo a variable containing an unescaped dollar sign in bash

If I have a variable containing an unescaped dollar sign, is there any way I can echo the entire contents of the variable? For example something calls a script: ./script.sh "test1$test2" and then if I want to use the parameter it gets "truncated" like so: echo ${1} test1 Of course single-quoting the varaible name doesn't help. I ca...

What's the best practice method for storing raw php, javascript, html or similar in a mysql database?

The example web page has 2 fields and allows a user to enter a title and code. Both fields would later be embed and displayed in an HTML page for viewing and/or editing but not execution. In other words, any PHP or javascript or similar should not run but be displayed for editing and copying. In this case, what is the best way to escape...

How to Search the Internet for '@'

I'm trying to figure out the context of an @enclosed@ variable in a .properties file, whether it refers to a variable in Java, UNIX, or something else. But try as I might I can't figure out how to search the internet for '@'. Google strips it from searches, even though its search suggestions will include it (and are currently more useful...

what's the escape sequence for hyphen (-) in PostgreSQL

Hi, I'm trying to rename a database to a name with a hyphen (-). ALTER DATABASE one RENAME TO one-two; And psql returns an error: ERROR: syntax error at or near "-" What should I use as an escape sequence for "-" character or what's the way to do the above? Note: I've tried the '\-' and didn't work as well. Thanks. ...

Quotes in command line arguments passed to Java main()

I run a Java program with the following command line (Edit: in NetBeans 6.8 project properties) toto has:"tutu titi" args is an array of 2 Strings toto has:tutu titi I want (two arguments indeed, the second) args[1] to be has:"tutu titi" How should I do that? Edit: I have already tried escaping the quotes with backslash from "...

escaping: "var name = '</script>'"

our middle tier needs to do something to prevent </script> from appearing verbatim in javascript string. for example, in all browsers, the HTML parser in its first pass will ignore the javascript context, see the first close-script, then see garbage then see a second close-script. See: using-script-in-a-javascript-literal <HTML> <BODY> ...

How do you escape a semicolon in COMPILE_FLAGS property of cmake ?

I need to get this as a result in the preprocessor definitions of the msvc generator: MYPATH=\"d:\\;.\\Lib\" But when I use the following escape sequence in set_source_files_properties: set_source_files_properties(source.c PROPERTIES COMPILE_FLAGS "-DMYPATH=\\\"d:\\\;.\\\\Lib\\\"") the generated result is: MYPATH=\"d:\";".\Lib\" ...

Safely escaping arguments on the command line in C#

I'd like to pass some user supplied arguments to an application (using C# on Windows). The arguments are in a NameValueCollection and I wish to pass them as a string so that the application can be invoked using the supplied arguments and invoked using ProcessStartInfo: ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.UseS...

Escaping large number of characters for display on XHTML web page via Java.

I have an embedded device which runs Java applications which can among other things serve up XHTML web pages (I could write the pages as something other than XHTML, but I'm aiming for that for now). When a request for a web page handled by my application is received a method is called in my code with all the information on the request i...

-o: command not found

I am trying to download file using curl, but I get the following error message. -o: command not found My command was curl http://lab.test.com/test/test/down.php?c=redsoul&amp;bbs_no=236513&amp;file_num=7061013&amp;filename=%EC%95%84%EC%9D%B4%EC%96%B8%EB%A7%A8%2003%ED%99%94%20%28ANIMAX%201280x720%20x264%20AAC%29.SMI&amp;size=25485 ...

i18n on Ruby on Rails, < and > gets replaced by &gt ; &lt ; when not intended

I am creating locale files for internationalization in a rails app, and have a url that I want translated with tags included , for example html.erb <%= t(foo.bar.xxxx) %> yml file foo: bar: xxxx: "xxxx" result &lt ;a href= "/info/index.html"&gt ;xxxx</a&gt ; which breaks my links. I do not have an h on th...

using Python to generate a C string literal of JSON

I have a dictionary in Python that I would like to serialize in JSON and convert to a proper C string so that it contains a valid JSON string that corresponds to my input dictionary. I'm using the result to autogenerate a line in a C source file. Got it? Here's an example: >>> import json >>> mydict = {'a':1, 'b': 'a string with "quotes...

JDialog: How to disable the ESC key of my Modal dialog?

So there's a frame (main app). From here, I open a Modal JDialog and start a background thread working whilst displaying progress (log entries) in a table. This process is critical and should not be stoppable/hideable/closeable, thus why the dialog's close button is de-activated until everything's finished. However, the user can at any t...

RegEx with strange behaviour: matching String with back reference to allow escaping and single and double quotes

Hi, community. Matching a string that allows escaping is not that difficult. Look here: http://ad.hominem.org/log/2005/05/quoted_strings.php. For the sake of simplicity I chose the approach, where a string is divided into two "atoms": either a character that is "not a quote or backslash" or a backslash followed by any character. "(([^"...

How to properly escape quotes inside html attributes?

I have a drop down on a web page which is breaking when the value string contains a quote. The value is "asd but in the DOM always appears as an empty string. I have tried every way I know to escape the string properly but to no avail. <option value=""asd">test</option> <option value="\"asd">test</option> <option value="&quot;asd">t...

Problem with simple regex

Hi all, I have the following regular expression in a validation rule: ^[a-zA-Z0-9',!;?~>+&\"\-@#%*.\s]{1,1000}$ However, I can enter ====== which I believe should not be allowed. My thoughts is that somehow the - could cause trouble if not properly escaped or something but this is way over my head. ...

Process escape sequences in a string in Python

Sometimes when I get input from a file or the user, I get a string with escape sequences in it. I would like to process the escape sequences in the same way that Python processes escape sequences in string literals. For example, let's say myString is defined as: >>> myString = "spam\\neggs" >>> print(myString) spam\neggs I want a fun...

PHP function to escape MySQL regexp syntax

I'm looking for something similar to preg_quote, but for the MySQL regexp syntax. Any ideas? ...

PHP Regex No Backslash

So I hadn't done any regexps for a while, so I thought I'd brush up on my memory. I'm trying to convert a string like a*b*c into a<b>b</b>c. I've already gotten that working, but now I want to keep a string like a\*b\*c from turning into a\<b>b\</b>c, but rather, into a*b*c. Here's the code I'm using now: $string = preg_replace("/\...

How to escape a % sign in a configobj value?

I'd like to use both parse time and runtime interpolation for values of a configobj configuration file. The easiest way to do simple string interpolation in Python is "%(foo)s" % somedict. Unfortunately configobj uses the same interpolation mechanism and I have not yet found a way to escape it. Ideally my value would look like: othervar...