java – HTML String Inside Nested String

java – HTML String Inside Nested String

Here you get to the fun of strings interpreted multiple times. your quotes need to be escaped for java, but your quotes need to be escaped for javascript. Thus, your quotes you can escape normally, but your quotes need the character to be in front of them when the javascript is interpreted, so you need a literal in your java string (or , an escaped ). thus, if you set your html variable to the html:

<span class=class>Heres Johnny!</span>

youll need to do:

String html = javascript:var html=<span class=class>Here\s Johnny!</span>;void(0);;

In most languages double quotes can be placed inside double-quoted string by escaping them:

This is a quoted string: Im a quoted string.

The need of such thing (inserting js code with strings into Java string) may indicate, that your code design isnt ok.

java – HTML String Inside Nested String

Leave a Reply

Your email address will not be published. Required fields are marked *