How to use semicolons in javascript injected? [closed]

-4

How can I write an alert whose content has a semicolon ; if it is considered as a syntax element?

Example:

<span onmouseover="alert("isso significa bla bla; voce acredita?";>Isso</span>
    
asked by anonymous 18.01.2018 / 21:50

1 answer

1

It will only be part of the JavaScript syntax if it is outside the string, strings begin and end with quotation marks:

"..."

Or apostrophes:

'...'

The problem with your script is that you are using " in HTML and alert (which is Javascript injected) at the same time, except that a HTML closing quote is missing:

<span onmouseover="alert("isso significa bla bla; voce acredita?");>isso&lt/span>

To avoid this, within the events in the HTML attributes use only apostrophes, test:

<span onmouseover="alert('isso significa bla bla; voce acredita?');">isso</span>

You can also use the &quot; entity within the HTML event attribute, which will be equivalent to the quotation marks:

<span onmouseover="alert(&quot;isso significa bla bla; voce acredita?&quot;);">isso</span>
    
18.01.2018 / 22:11