escaping

PHP Echoing JSON string into HTML Input value - Need character escape

烂漫一生 提交于 2020-01-30 05:21:24
问题 Here is a simplified version of my code that I am having a problem with. $variable = "{\\\"JSON" //long JSON string created in Javascript with JSON.stringify ?> <input type="text" name="somename" value="<?php echo $variable; ?>"/> <?php The input box only contains {\ I need a way to escape the entire JSON string Thanks Alex 回答1: You're outputting into an HTML context, so you need html-specific escaping: <input ... value="<?php echo htmlspecialchars(json_encode($whatever)); ?>" /> ^^^^^^^^^^^^

How to disable/avoid Ampersand-Escaping in Java-XML?

杀马特。学长 韩版系。学妹 提交于 2020-01-29 07:12:32
问题 I want to create a XML where blanks are replaced by   . But the Java-Transformer escapes the Ampersand, so that the output is &#160; Here is my sample code: public class Test { public static void main(String[] args) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.newDocument(); Element element = document.createElement("element"); element.setTextContent(" "); document.appendChild

How to disable/avoid Ampersand-Escaping in Java-XML?

我的梦境 提交于 2020-01-29 07:11:25
问题 I want to create a XML where blanks are replaced by   . But the Java-Transformer escapes the Ampersand, so that the output is &#160; Here is my sample code: public class Test { public static void main(String[] args) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.newDocument(); Element element = document.createElement("element"); element.setTextContent(" "); document.appendChild

Escaping a batch file echo that starts with a forward slash and question mark

淺唱寂寞╮ 提交于 2020-01-28 00:07:34
问题 Bit of a tricky one. How can I correctly escape the following in a batch file? echo /? display this help text This particular combination of characters is treated as an "ECHO /?" command: C:\Batch>ECHO /? display this help text Displays messages, or turns command-echoing on or off. ECHO [ON | OFF] ECHO [message] Type ECHO without parameters to display the current echo setting. It does not respond to caret (^) escaping, ie. I've tried ^/? /^? and ^/^?. NB: As a workaround, I found that

NodeJS RTF ANSI Find and Replace Words With Special Chars

六眼飞鱼酱① 提交于 2020-01-25 11:09:05
问题 I have a find and replace script that works no problem when the words don't have any special characters. However, there will be a lot of times where there will be special characters since it's finding names. As of now this is breaking the script. The script looks for {<some-text>} and attempts to replace the contents (as well as remove the braces). Example: text.rtf Here's a name with special char {Kotouč} script.ts import * as fs from "fs"; // Ingest the rtf file. const content: string = fs

Fix a batch script to handle closing parentheses inside an if block

霸气de小男生 提交于 2020-01-25 03:10:12
问题 I have a batch script to run different PHP versions under different environments. @ECHO OFF setlocal EnableExtensions EnableDelayedExpansion IF "%ANSICON%" == "" ( php7 %* ) ELSE ( php5 %* ) The problem is it breaks on the first unescaped closing parenthesis as it matches the opening parenthesis in IF "%ANSICON%" == "" ( . C:\>php -r echo'()'; ' was unexpected at this time. C:\>php -r echo'(())'; )' was unexpected at this time. The line setlocal EnableExtensions EnableDelayedExpansion is new

Escape ampersand with SQL Server

ε祈祈猫儿з 提交于 2020-01-24 20:20:09
问题 I have this SQL-Server query UPDATE qryPETEUR_frmPricingModel() SET G&A = '68442.0000' WHERE comp_id = '10004' Which fails because Incorrect syntax near '&' The query works when I change the field being edited to something without an ampersand, so I think the ampersand is the problem. Unfortunatly I am stuck having to use the use the field G&A and can't change it. What can I do to get this query working. I think I have to escape the ampersand, but I can't figure out how. I have tried adding \

Putting sample XML code in Javadoc

北城以北 提交于 2020-01-24 05:45:06
问题 How to put a sample XML code in Javadoc? The XML code includes angle brackets which I do not want to be processed. I tried combinations of PRE and code but it didn't work. 回答1: You can use @code javadoc tag. Take a look to this post, wich contains some examples. Hope it helps 回答2: You have to use HTML/XML encoding like &lt; for < and &gt; for >. If you use Eclipse, there is a Javadoc view that shows you a preview. 来源: https://stackoverflow.com/questions/26588234/putting-sample-xml-code-in-javadoc

CKEditor escape html

不羁岁月 提交于 2020-01-24 00:40:15
问题 I have CKEditor on post text where I want to insert html-code. Something like this: <pre> <code class="html"> <img src="path/to/img.jpg" /> </code> </pre> But when I save the text, CKEditor interprets img-tag as actual html-image and shows broken image. How I can prevent that and tell to escape html-code in pre-code block 回答1: <pre> <code class="html"> <img src="path/to/img.jpg" /> </code> </pre> This is an image inside a pre element. What you want to create is: <pre> <code class="html"> <img

Prevent URL-encoding of characters in link in MediaWiki

假装没事ソ 提交于 2020-01-23 04:12:27
问题 I.e.: How to suppress substitution/replacement of characters with its html entities in a MediaWiki link? I need to insert a link looking like this, pipes ( | ) included, into a MediaWiki article: http://www.somesite.asdf/#|param1|param2|param3 The target site does not accept %7C or | as pipe-substitutes in its URL. Ergo, the following URLs are invalid: http://www.somesite.asdf/#%7Cparam1%7Cparam2%7Cparam3 http://www.somesite.asdf/#|param1|param2|param3 When I type the link into the MediaWiki