473,657 Members | 3,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unescape escapeXML text

Hi All,

I have an application that is writing Javascript with JSP server side
code that uses escapeXML:

var someVar = "<c:out escapeXml="true " value="You'll never escape!"/
>";
How to I unescape this? Using the unescape() function doesn't cut
it..
unescape("You'l l never escape!");

Do I have to use regex to replace or is there some other way?

Thanks for any assistance!

Rob
:)
Oct 14 '08 #1
4 11382
Robert Mark Bram wrote:
I have an application that is writing Javascript with JSP server side
code that uses escapeXML:

var someVar = "<c:out escapeXml="true " value="You'll never escape!"/
";

How to I unescape this? Using the unescape() function doesn't cut
it. unescape("You'l l never escape!");

Do I have to use regex to replace or is there some other way?
var txt = 'apostrophe ' / double quote: " / '
+ ' s: s / è: è / Chinese sign: 新';

txt = txt.replace(/(&#)([0-9]{1,5})(;)/g,
function (a1, a2, a3, a4) {
return String.fromChar Code(a3);
}
);
alert(txt);

Hope this helps,

--
Bart
Oct 14 '08 #2
Robert Mark Bram wrote:
Hi All,

I have an application that is writing Javascript with JSP server side
code that uses escapeXML:

var someVar = "<c:out escapeXml="true " value="You'll never escape!"/
>";

How to I unescape this? Using the unescape() function doesn't cut
it..
unescape("You'l l never escape!");
Or could escape it differently.

If you are using struts you can use StringEscapeUti ls.escapeJavaSc ript.

Would be really nice to have c:out handle that.

Fictitious example:
<c:out escapeJavaScrip t="true" value="You'll never escape!"/>

Garrett
>
Rob
:)

--
comp.lang.javas cript FAQ <URL: http://jibbering.com/faq/ >
Oct 14 '08 #3
Robert Mark Bram wrote:
I have an application that is writing Javascript with JSP server side
code that uses escapeXML:

var someVar = "<c:out escapeXml="true " value="You'll never escape!"/>";
*g*
How to I unescape this?
Maybe

someVar = someVar.replace (/&lt;/g, "<").replac e(/&gt;/g, ">"
.replace(/&amp;/g, "&");
Using the unescape() function doesn't cut it..
unescape("You'l l never escape!");
It is not supposed to. unescape() decodes (ASCII) percent-encoded strings.
It was primarily used to decode URI components, and is now deprecated in
favor of decodeURI() and decodeURICompon ent(), which in addition can decode
UTF-8 percent encoding.
Do I have to use regex to replace or is there some other way?
A regular expression like above would not help in your case because the
escaping of `"' needs to take place *before* you insert the value with JSP,
i.e. "on the server".

You do not need `escapeXml="tru e"' if you declare the content of the XHTML
`script' element CDATA, provided the string never contains `"', like
in your example:

<script type="text/javascript">
// <![CDATA[
...
]]>
</script>

But if the `<' and `>' are your only problems, you could as well move the
code to an external script file or simply use HTML instead.
PointedEars
--
var bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.js:16
Oct 15 '08 #4
Thanks to all for the input!
Oct 16 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5524
by: koen colen | last post by:
Hello group, I hope you guys can help me out, I am modifying a piece of code from Joe Norman, I did found the code here: http://www.intranet2internet.com/public/default.asp?PAGE=sscript&ID=3 My question: How can I save the value's of a form to a cookie, but in the textarea's of that form the "hard returns" must be saved with it?
2
3997
by: karteikarte | last post by:
hey, i just found this riddle somewhere in the net: <meta http-equiv="Pragma" content="no-cache"> <script language="JavaScript"> <!-- function nstie(){return false}function nstns(){if(document.layers){st=document.getSelection();if(st!=""&&st!=" "){window.find(" ")}setTimeout("nstns()",20)}}nstns();document.onselectstart=nstie;ondragstart=nstie;function nrcie(){return false}function
1
3183
by: Harry Keck | last post by:
Is there a set of methods in the .Net framework that do the same thing as the jscript functions escape and unescape? I get very close with HttpUtility.UrlEncodeUnicode, but it puts "+" for spaces instead of "%20". Uri.EscapeString seems to create the correct escape string, but there is no unescape. The function is not public anyway, so I probably shouldn't use it. I need a way to escape text on the client, and then unescape it on the...
30
4638
by: mistral | last post by:
Neeed good javascript unescape encoder, to protect javascript code. Some advices? Online tool, or ready javascript only. Any opinions about the Javascript Obfuscator: http://www.javascript-source.com/
2
10934
by: Richard Lewis Haggard | last post by:
Is it possible to use features from XmlDocument to unescape text back to its original raw text format after it has been escaped to handle non-HTML compliant character strings? I have code that serializes text to an XML file and then deserializes back to text. If the user enters XML illegal text like "<Actor1>", the code properly escapes it to "&lt;Actor1&gt;", something that doesn't interfere with the XML syntax, and writes it into the Xml...
2
28162
by: Richard Lewis Haggard | last post by:
Is it possible to use features from XmlDocument to unescape text back to its original raw text format after it has been escaped to handle non-HTML compliant character strings? I have code that serializes text to an XML file and then deserializes back to text. If the user enters XML illegal text like "<Actor1>", the code properly escapes it to "&lt;Actor1&gt;", something that doesn't interfere with the XML syntax, and writes it into the Xml...
3
6850
by: mistral | last post by:
How to decrypt this text, what algorithm used to encode text, how to recreate algorithm? %c3%99%c3%a3%c3%af%c3%b3%c3%94%c3%92%c3%89%c3%81%c3%8c%c3%ae%c3%ba %c3%b9%c3%9b%c3%bc%c2%b0%c2%b2%c3%aa%c3%a4%c3%a9%c3%b1%c3%bc %c3%a9%c3%b2%c3%ac%c3%ad%c3%86%c3%95%c3%8c%c3%8c%c3%a1%c3%a9%c3%aa %c3%b4%c3%bc%c2%b0%c2%b2%c3%ac%c3%a9%c3%ac%c3%b1%c3%a6 decoding with unescape does not work it seems.
1
4185
by: RK | last post by:
Perhaps I'm confused somwhere in my understanding, but I'm trying to deal with some escaped text from an XML file which includes html markup and it appears there are a couple of techniques for escape codes. (I hope I can describe my issue here without having to worry about how to escape it for display on this group!) On the server-side I extract some text from an XML file, which includes some style and content. The XML is simply:
0
8384
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8302
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8820
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8499
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5630
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.