Skip to content

securityeasy

Escape It Before You Render It

75 points · 0 solved

Cross-site scripting (XSS) happens when user text is dropped into HTML as-is. The first line is T; each of the next T lines is untrusted text. Print each line HTML-escaped: &→&amp;, <→&lt;, >→&gt;, "→&quot;, '→&#x27;. Every other character stays the same.

Escape & first in your head — &lt; in the input must become &amp;lt;.

2
<b>hi</b>
5 > 3 & 2 < 4
&lt;b&gt;hi&lt;/b&gt;
5 &gt; 3 &amp; 2 &lt; 4
Learn the technique/learn/secure-coding-in-practice

main.py