Questions tagged [escaping]

Escaping refers to the act of assigning an alternative interpretation to a specific character or group of characters.

Tips on avoiding special characters in SPARQL Prefixed Names

I have been using SPARQL and Python to query DBpedia. Unfortunately, I encounter an error whenever I include special characters like parentheses in my requests. My attempts to escape the characters with backslashes have been unsuccessful (as shown in the ...

What is the proper way to encode image URLs for use in CSS?

For the div element in my code, I want to allow users to input a URL that will be applied as a CSS background image, like this: background-image: url("/* user specified URL here*/") I'm concerned about security. How can I properly escape the URL to ...

Despite having magic_quotes_gpc turned off, jQuery Ajax still escapes strings

Even with magic_quotes_gpc = off on the server, the data I send via jQuery Ajax is still being escaped. When getting data directly from $_POST without using ajax, everything works fine and the data remains unescaped. However, when sending data through aja ...

In PHP, single quotes present a challenge for prepared statements when it comes to escaping

When I was faced with the issue of single quotes causing problems when inserting values into MySql for sign up, I turned to prepared statements as a solution. Previously, I had used addslashes but found that it only worked for specific queries. Let me elab ...

Node.js: How to handle spaces when running a UNIX command

Currently, I am utilizing the following command to compress files in node.js: var command = '7z a ' + dest + ' ' + orig; exec( command, function(err, stdout, stderr) { ...}); An issue arises when a file containing spaces is involved, for instance 7z a my ...

Dealing with issues escaping unicode characters in JavaScript

Whenever I need to load data from an external file based on a specific event, I make use of the following jQuery code: $("#container").load("/include/data.php?name=" + escape(name)); An issue arises when the JavaScript variable "name" contains Unicode ch ...

Using JSON_ENCODE may attempt to evade double quotes

I have a controller that retrieves data from my database, formats it as valid JSON, but the HTTP response is text/html instead of application/json. This causes issues with getJSON not working properly. Should getJSON work regardless? public function send ...

What causes the inconsistency in single quote escaping when reading files in Python?

When I open two similar text files on MacVim and read them into Python variables, I notice that their content behaves differently. Can someone explain why this happens and suggest a solution to ensure consistent behavior? Here is an example, where f1.txt ...

Efficiently handling the conversion from backslashes (\) to single

We are facing a challenge in producing a unique string format: "/Date()/". It is important to note that backslashes do not function as escape characters in this case; rather, they represent the literal string. Our .NET team member suggested using syntax ...

Including a unicode escape sequence in a variable string value

I'm struggling to find the right way to include a unicode escape in a dynamic string value to display emojis in React. My database stores the hexcode for the emoji (1f44d) I have set up a styled-component with the necessary css for rendering an emoj ...

The oddity of a lone quotation mark trying to break

var x = "Test \'" > undefined var y = "Test '" > undefined x === y > true x > "Test '" https://i.stack.imgur.com/ZrHo5.jpg Aha! Both of these strings are actually equal (as shown in the example code) - but why is that the ...

What could be causing replace() to malfunction in Node.js?

I am dealing with some data in Node.js and I am trying to replace the ampersands with their escape key. Below is the code snippet I am using: let newValue = data; for (label in labelData.data) { let key = "Label " + label; newValue = newValue.rep ...

Is it safe to use handlebars' default escaping in HTML attributes?

Currently, I am working on a project where various HTML escaping methods are being utilized. Some properties are escaped in the backend and displayed as raw strings using triple handlebars {{{escaped-in-backend}}}, while others are passed from the backend ...

Strings in Godot's gdscript containing escape characters retrieved from a database

I've been grappling with escape characters while developing a dialogue system in gdscript. My tool of choice is CastleDB, which has made it convenient to store nearly everything in data and empowering the writers to work on content outside the engine witho ...

Inject HTML entities, escaped for CSS, dynamically using JavaScript

My goal is to dynamically generate a list of HTMLElements with unique data-* attributes that correspond to various HTML Entities. These attributes will then be utilized by CSS to display content in pseudo elements like this: li:after { content: attr(dat ...

Combining JS and PHP for secure function escaping

Looking for a solution to properly escape quotes in generated PHP Javascript code. Here is an example of the current output: foreach ($array as $element) { echo '<a onClick="myFunctionTakesPHPValues('.$element[0].','.$element[1] ...

Problem with escaping special characters in random string HTML

As I was in the process of creating a JavaScript tool to generate random strings, with or without special characters, I stumbled upon an inspiring snippet that caught my attention: (): function randStr(len) { let s = ''; while (len--) s += String.fr ...

When using JsonConvert.DeserializeObject from Newtonsoft.Json, the issue of losing a non-printable ASCII character (specifically the group separator) during deserialization may

I have encountered a puzzling issue that I am struggling to resolve. My current task involves deserializing JSON data using Newtonsoft.Json. After inspecting the raw JSON string, I noticed certain character sequences: { '\\', 'u&ap ...

Unable to execute a Windows command line that has been escaped within Python

When I execute the given command in a Windows command prompt, it works flawlessly. java -jar "C:\Program Files (x86)\SnapBackup\app\snapbackup.jar" main However, when I attempt to run the same command within a Python script, it fails. ...

Avoiding special characters in URLs

Is there a way to properly escape the & (ampersand) in a URL using jQuery? I have attempted the following methods: .replace("/&/g", "&amp;") .replace("/&/g", "%26") .replace("/&/g", "&") Unfortunately, none of these are yieldi ...

Scala string: Unescaping made easy

I have come across numerous discussions on escaping strings, but none on de-escaping them. When working with Scala Play, my controller takes in a JSON request. I retrieve a string from it using the following code: val text: play.api.libs.json.JsValue = r ...

Avoiding certain characters in elasticsearch for indexing

Utilizing the elasticsearch python client to execute queries on our self-hosted elasticsearch instance has been quite helpful. I recently discovered that it is necessary to escape certain characters, such as: + - && || ! ( ) { } [ ] ^ " ~ * ? : ...