#0903
Your server embeds a user-controlled value directly into a JavaScript string literal in the HTML response: var name = "<OUTPUT>";.
The safeJsonValue function currently only escapes < and >, leaving backslashes, double-quotes, and newlines unescaped.
An attacker can inject "; alert(1); var x=" to break out of the string literal and execute arbitrary JavaScript in the victim's browser.
Injecting into JavaScript string literals is a common server-side XSS vector when applications inline JSON or user data into script blocks. A single unescaped quote or newline can give an attacker full script execution.
safeJsonValue to escape all characters that could break out of a JavaScript string literal.\ → \\, " → \", newline → \n, carriage return → \r, </ → <\/.safeJsonValue('"'); alert(1);//')// var name = ""; alert(1);//"; — script executes!
safeJsonValue('"')// returns '\"'
</ sequence must be escaped to prevent premature </script> tag termination.