This web page contains JavaScript code that mimics the behaviour of a web server that generates a web page using the template below. The template applies some encodings (aka sanitisations) to limit the possibility for (malicious or accidental) weird input causing problems, such as XSS, corrupting links, or simply breaking stuff.
User info for $htmlEscaped(name)}
Click here for a silly pop-up
`);If you want to go to ${name}'s name homepage, click here.
Note that first HTML-encoding and then JS-string-literal encoding the name in the onmousedown tag is probably not be the best solution. Also, as we found out in class, the template forgets to encode name in the last line of the template.
Hitting the buttons below executes a JavaScript function generateWebPage that uses the values above to generate an HTML web page. The buttons use two different techniques provided by the DOM API to get your browser to render the generated HTML: innerHTML and document.write().
Here the generated webpage will appear