Questions tagged [escaping]

Escaping is the process of applying an alternate meaning to a character or set of characters.

Escaping is used for many purposes, such as providing representations of unprintable characters, changing font colors in terminals, or allowing the inclusion in a string of a character normally used to terminate the string, as well as allowing to output a character to user when that character can be used as a control or markup character.

Some of the more common uses of escaping

  • URL encoding to allow including characters such as / or ?, and others, in URL queries;
  • XML and HTML entities that can be used to encode special characters that, for example, would normally be used for markup purposes.
8924 questions
4
votes
3 answers

How to escape output in PHP

I am a newbie, just to be clear. I hear a lot about escaping data to prevent XSS attacks. How do I actually do that? This is what I am doing currently - $s = mysqli_real_escape_string($connect,$_POST['name'])); Is this enough? Thanks
Chrism
  • 67
  • 1
  • 1
  • 5
4
votes
2 answers

best way to escape data JS->PHP->MySQL and vice versa

what functions i have to use to encode/decode/escape/stripslash data for following purposes? when calling a PHP script from JS like: page.php?data=don't_use_#_and_%_in_URL_params when a PHP script receive a parameter from JS like:…
SYNCRo
  • 450
  • 5
  • 21
4
votes
1 answer

Escaping special characters in a variable in PowerShell

I have a variable in PowerShell that contains special characters like "<",">" and double quotes. Currently I am using something like -replace ">" , "^>" , -replace "<" , "^<", -replace '"' , "'". Is there a way to escape all special characters in…
loct
  • 357
  • 2
  • 5
  • 21
4
votes
2 answers

Escaping Shell echos

I tried to do my research, there is just an abundance of ways to call shell commands, and even more ways to strip harmful characters that I am coming to stackoverflow for an expert's best recommendation. I was hoping to find something like I've seen…
ParoX
  • 5,685
  • 23
  • 81
  • 152
4
votes
2 answers

Sed with special caracters

How can I replace this with sed ? I need to replace this: set $protection 'enabled'; to set $protection 'disabled'; Please note that I can't sed the enabled to disabled because it's not only used at this location in the input file. I tried this…
Jobine23
  • 129
  • 9
4
votes
2 answers

Quoted printing of shell variables

I would like to print the contents of a variable in such a way, that the printed output could be pasted directly into a shell to get the original content of the variable. This is trivial if the content doesn't contain any special characters, esp no…
umläute
  • 28,885
  • 9
  • 68
  • 122
4
votes
4 answers

PHP: escape filename as linux does

I'm having troubles with filenames upload by users which I have to process. When I try to access them, because some of them have special characters, the command used says the file is not found or similar. I've used escapeshellcmd with no…
FlamingMoe
  • 2,709
  • 5
  • 39
  • 64
4
votes
3 answers

how to escape semicolons when writing to csv in python

I have a list of lists in python that represents data to be written in a csv file. My code for that is : for n, d, p in zip(names, dates, posts): writer.writerow([i, n, d, p]) However, some of the strings in posts contain semicolons, and…
Z Wang
  • 41
  • 3
4
votes
3 answers

What would be a good way to deal with backslash escaped characters?

I have a string in the following format; s="part1,part2,part3,part4" I can split the string into pieces by just invoking the s.split(",") command. Now, the question is what if I have a backslash escaped comma in the string? Assuming I have the…
Utku Zihnioglu
  • 4,714
  • 3
  • 38
  • 50
4
votes
6 answers

How are strings escaped for each database extension in php?

Before anyone jumps to conclusions as to the nature of this question, I already know about parameterized/prepared statements and use them whenever possible. Unfortunately, it is not always possible to use them when building dynamic queries. I'm…
zzzzBov
  • 174,988
  • 54
  • 320
  • 367
4
votes
3 answers

kotlin String::replace removing escape sequences?

I'm trying some string manipulation using regex's, but I'm not getting the expected output var myString = "/api//" myString.replace(Regex(""), "(\\d+)") this should give me something like /api/(\d+)/ but instead I get…
Ishan Khare
  • 1,745
  • 4
  • 28
  • 59
4
votes
3 answers

How to escape special characters in query string sent via JQuery ajax function?

I need to POST short messages to the server. Sometimes they have special characters, like in this example: &message=Joining a game of Commands & Colors: Ancients. How do I escape special characters from a query string? I'm using Django. Here's…
Will Curran
  • 6,959
  • 15
  • 59
  • 92
4
votes
2 answers

Prevent javascript from auto escaping & character

I am seeing & in my textbox but I only want &. I think it is something to do with the way browser interpret javascript .innerHTML. The text with & must pass through div. For some reason, I can't directly assign value to the text box. HTML…
Clinton Lam
  • 687
  • 1
  • 8
  • 27
4
votes
3 answers

mysql_real_escape_string for multibyte without a connection?

let's consider i will always do a SET NAMES 'utf8' to mysql connection (so I need multibyte escapes). Is there a safe alternative to mysql_real_escape_string that doesnt' need a mysql connection? In the official page i found a comment that uses…
dynamic
  • 46,985
  • 55
  • 154
  • 231
4
votes
1 answer

In R, how to unescape a JSON object saved in a string

I have the following JSON saved as a string in R, however due to the way that the string is being read into R, the string is escaped twice. Here it is: > myJsonString = "{\\r\\n \\\"type\\\": \\\"service_account\\\",\\r\\n \\\"project_id\\\":…
Canovice
  • 9,012
  • 22
  • 93
  • 211