escaping

Unescape HTML entities containing newline in Javascript?

北慕城南 提交于 2019-12-22 09:01:46
问题 If you have a string containing HTML entities and want to unescape it, this solution (or variants thereof) is suggested multiple times: function htmlDecode(input){ var e = document.createElement('div'); e.innerHTML = input; return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue; } htmlDecode("<img src='myimage.jpg'>"); // returns "<img src='myimage.jpg'>" (See, for example, this answer: https://stackoverflow.com/a/1912522/1199564) This works fine as long as the string does not

How to escape only certain characters

柔情痞子 提交于 2019-12-22 08:34:47
问题 php function preg_quote escapes these characters . \ + * ? [ ^ ] $ ( ) { } = ! < > | : - Could you please suggest what I could use to escape these characters: + - && || ! ( ) { } [ ] ^ " ~ * ? : / Edited (as requested by "on hold"): I'm implementing a Solr search and it says: Solr gives the following characters special meaning when they appear in a query: + - && || ! ( ) { } [ ] ^ " ~ * ? : / To make Solr interpret any of these characters literally, rather as a special character, precede the

How do I escape curly braces {…} in powershell?

蹲街弑〆低调 提交于 2019-12-22 08:26:29
问题 I need to generate multiple lines of xml tag with a GUID in them: <xmltag_10 value="{ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ}"/> <xmltag_11 value="{ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ}"/> and so on I have this line in a loop where $guid is generated each iteration, and it prints the guid without surrounding braces Write-Host ('<xmltag_{0} value="{1}"/>' -f $i,$guid) <xmltag_10 value="ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ"/> Adding a set of curly braces, I get Write-Host ('<xmltag_{0} value="{{1}

Escape asterisk in Windows Batch File's FOR Loop

北城以北 提交于 2019-12-22 08:08:21
问题 When running the following code in a windows batch file everything works aside from the string containing the asterisk, which is skipped. Checking the passed parameters by number (i.e. echo(%~6 ) I can see the asterisk - it's only when passed to the FOR loop that I have an issue: @echo off setlocal enableextensions enabledelayedexpansion call:Concat cmd "this is a demo" " of concat functionality." " Hopefully it will work;" " but it doesn't when I pass an" " * asterisk" " character" echo !cmd

Inserting HTML to golang template [duplicate]

柔情痞子 提交于 2019-12-22 07:58:18
问题 This question already has answers here : Go template.ExecuteTemplate include html (8 answers) Closed 6 months ago . I have a template in golang where I have a string that looks something like this: <some_html> {{ .SomeOtherHTML }} </some_html> I'm expecting an output to be something like this: <some_html> <the_other_html/> </some_html> But instead I'm seeing something like this: <some_html> <the_other_html/< </some_html> I'm also trying to insert some JSON but golang is escaping characters

Remove the escape sequence '\' from string to convert it to XmlDocument

て烟熏妆下的殇ゞ 提交于 2019-12-22 06:51:04
问题 I have a web service which returns a struct object, so I get the response as the following XML string. Now I need to load it into XmlDocument object but how do I get rid of the escape sequences in the string. The '\' with every '"' is causing error. <?xml version=\"1.0\" encoding=\"utf-8\"?> <Quote xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://tempuri.org/\"> <price>19656</price> </Quote> 回答1: Use Regex.Unescape method.

Can anyone identify this encoding?

不问归期 提交于 2019-12-22 05:48:19
问题 Im working on a program to interface with some hardware that is sending data that has been encoded and wrapped to send within a CDATA block in an XML document. the software in the device as far as I know is written in Python and i'm writing the interface in Delphi. the data the device sends is this \x00E\x18\x10\x14}*UF!A\x81\xac\x08&\x02\x01\n\x15\x1a\xc2PP\x92\x17\xc2\xc1\xa0\x0e\x1a\xc2\xd0K\x94\'\x830\x11\x8b \x84a_\xa0+\x04\x81\x17\x89\x15D\x91B\x05.\x84\xf1\x1b\x89%E\x00\x04\x9c\x0e\xc5

How to define ESC char in git?

纵然是瞬间 提交于 2019-12-22 05:23:34
问题 I want to use coloring in git output, e.g.: git log --decorate --color When I issue this command I get output looking like ESC[1;32m where ESC is in reversed color. This looks to me as a valid escape sequence, except that the \033 must be sent and not the characters E , S and C . When I issue an ls command, I get coloring of the files according to the rights. So nothing wrong with the capabilities. Is there an environment variable that must be set to the value of the ESC char? Or am I looking

Should I escape an expected integer value using mysql_real_escape_string or can I just use (int)$expectedinteger

余生长醉 提交于 2019-12-22 05:14:24
问题 is it safe to use cast (int) instead of escaping? class opinion { function loadbyopinionid($opinionid){ $opinionid=(int)$opinionid; mysql_query("select * from fe_opinion where opinionid=$opinionid"); //more code } } 回答1: mysql_real_scape_string is for STRINGS . it will not make an integer 'safe' for use. e.g. $safe = mysql_real_escape_string($_GET['page']); will do NOTHING where $_GET['page'] = "0 = 0"; because there's no SQL metacharacters in there. your query would end up something like

Unescape special characters correctly from the URL in Rails 3.0.3

允我心安 提交于 2019-12-22 04:47:43
问题 I'm using Rails 3.0.3 with REE ( Ruby 1.8.7 ) and gem 'mysql2', '0.2.6' There's a search feature in my project that enable people to use the GET method using URL or using forms and then generate the URL. Example: I want to search: origin city: " Århus, Denmark " and destination city: " Asunción, Paraguay " they both have a special character: " Å " and " ó ", so the URL will be generated like this when someone click the search button. ?&origin=%C5rhus%2C%20Denmark&destination=Asunci%F3n%2C