#0902
Your application dynamically builds HTML attributes from user-supplied values, for example: <input value="{userValue}">.
The current escapeAttribute function only escapes < and >, leaving the double-quote character unescaped.
An attacker can supply a value like "> to break out of the attribute context and inject arbitrary JavaScript.
Attribute injection is one of the most exploited XSS vectors. A single unescaped quote or double-quote in an attribute value can allow an attacker to inject event handlers or entirely new HTML elements.
escapeAttribute so it escapes all five dangerous HTML characters.& → &, < → <, > → >, " → ", ' → '.escapeAttribute('">')// returns '">'// <input value=""> → attribute broken!
escapeAttribute('">')// returns '">'
& first to avoid double-escaping.