Questions tagged [escaping]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
80 views

Unquoting booleans, numbers, etc. in a JSON string

I have a method that takes a JSON string as input and "fixes" it. By that, I mean, that the JSON string comes in with all values quoted. My method un-quotes the values that shouldn't be quoted (i.e. ...
1
vote
2answers
134 views

Balanced parenthesis, with backslash escaping

Given a Balanced Parenthesis problem. "Balanced Parenthesis Create a program that checks if in a given string expression all the parenthesis are balanced. For Example: (test) - valid ...
3
votes
1answer
67 views

htmlspecialchars() equivalent in C

I'm trying to write an equivalent of PHP's htmlspecialchars() in C. What is my implementation missing or doing wrong? ...
6
votes
1answer
1k views

Python program that obfuscates an email address

I decided to resume my (limited) Python skills after not coding for a long time. Here's a very simple self-contained program to convert the characters of an email address into their HTML entities (...
3
votes
1answer
272 views

Displaying text extracted from XML using PHP simplexml

I have this xml file and i am parsing it with php simplexml. My XML file looks like this: ...
4
votes
2answers
62 views

Escaped line reader

The idiomatic way of reading lines from a file doesn't work for my purposes because the files I'm dealing with might have lines that are escaped. I came up with the below (which seems to meet my needs)...
4
votes
2answers
131 views

Interpreting strings with C-style escapes

I am working on a compiler that does a pretty heavy work on strings in order to get them correctly displayed. So far I have an algorithm that transforms a given string like (In plaintext): ...
1
vote
0answers
205 views

A class to stop XML parser from converting UTF-8 entity hex characters

I'm trying to stop the xml parser from converting the UTF-8 enitity hex codes to its character alternative and also not adding the extra space in self-closing nodes after parsing. I've created a ...
5
votes
1answer
107 views

Sublime Text plugin to modify text before it's pasted

It's my first plugin and it's super simple but there could easily be some things worth knowing from this e.g. Python coding practices and potential bugs. ...
0
votes
2answers
195 views

XSS Protection from Query Strings in Java

Looking for input on the code below. Generally, the idea is to take a String representing a URL query string such as param1=blah&param2=blah and encode them to ...
3
votes
0answers
547 views

Decoder for Content-Transfer-Encoding and Quoted-printable

Below are two utility functions I have written to help decode email messages in Mbox format. decodeTransfer decodes the message according to the Content-Transfer-...
1
vote
2answers
130 views

Encoding arbitrary data for stream transmission

Basically, what this function should do is encode an arbitrary set of data in memory to a series of bytes that starts with 0x02, ends with ...
2
votes
1answer
1k views

Escaping characters in a WMI Query

I've knocked up this code to allow me to query for specific service names using PowerShell. I'm after the executable (PathName) for the service, so the ...
8
votes
1answer
96 views

String escaper in C

As part of my stupidly large project Concaten, I'm writing a string escaper. It's the majority of the part that turns string tokens (like "hello world" or ...
4
votes
1answer
191 views

Raw replacement of space by %20 in Java

I tried coding this for practice. Is there a more memory-efficient way to work in place without using more arrays etc (using raw array operations)? ...
8
votes
5answers
6k views

Write a method to replace all spaces in a string with %20

I have implemented a solution to this Cracking the Coding Interview question: Write a method to replace all spaces in a string with %20. You may assume that the string has sufficient space at the ...
12
votes
3answers
16k views

Escape user input for use in JS regex

I am building a highlight feature for search results on my website and need to escape the user's input so that I could highlight the matching string within the original text. The function ...
3
votes
0answers
279 views

Escape Characters for LDAP/ADSI string

Below's some code I knocked up to escape the account name to be used in creating an ADSI reference to an account (e.g. escaping $sAmAccountName before using in <...
1
vote
1answer
839 views

Converting bytes to an escaped hexadecimal string

I wrote this function to convert an array of bytes to a C/C++ string representation using hexadecimal escape codes (\xhh). Any suggestions are welcome: ...
7
votes
2answers
3k views

Efficient URL Escape (Percent-Encoding)

Here I have a simple algorithm to percent-encode any string. (Specification from Wikipedia; note that this is not compatible with URLEncoder.encode()) Is this an ...
4
votes
2answers
123 views

Escape some char in a byte array

I am trying to construct a binary message packet. It needs to escape binary value 0 by appending extra 0 in front of it: ...
5
votes
2answers
3k views

My method of escaping MySQL strings in C++

This is how I'm currently escaping MySQL strings in C++: ...
2
votes
2answers
2k views

Preventing XSS attacks with proper escaping

The following page simulates XSS attacks and successfully (?) prevents them. I want to know if I've missed any other major attack vectors (or small ones) and/or if anyone has suggestions as to ...
3
votes
1answer
79 views

Escaping photo caption to avoid cross site script attack

I am a PHP newbie and this is part of a gallery code. I recently read about SQL injection and cross site scripting attack, I am trying to avoid that by html escaping on dynamically produced data. I am ...
4
votes
1answer
125 views

Sanitzing input on form submit with PHP

I was hacking around this morning and wanting to use automatically generate safe-to-use variables from $_POST. Probably not the best use of ...
6
votes
1answer
642 views

Is this escape unescape function pair correct?

Is this example of an escape - unescape function correct? ...
7
votes
3answers
914 views

Functions to escape CSS rules in PHP

Some context I've been tasked with supplying an escaping function to arbitrary CSS values that are entered through a form. The goals and caveats are: I know it's bad practice to let users input CSS. ...
3
votes
3answers
244 views

More Pythonic version of finding substring with one glob-like expression

Giving the following example list the task is: find out whether the second expression is in the first one. * shall be considered as a wildcard for any character ...