My question is very similar to this one, but without the <% %> details.
Let's say I have the following code:
public static IHtmlString AddSomethingToWindow(string value) {
var output = new StringBuilder();
output.AppendLine("<script type='text/javascript'>");
output.Append("window.something=\"" + value + "\";");
output.Append("</script>");
return new HtmlString(output.ToString());
}
Let's say value is coming from an untrusted source & could be anything.
To make RenderSomething method safe, do I need HttpUtility.HtmlEncode(HttpUtility.JavaScriptStringEncode(value)) or is just HttpUtility.JavaScriptStringEncode(value) sufficient? Or are both wrong?

