diff --git a/modules/api/views.js b/modules/api/views.js index 00bdbe74a..c555d1136 100644 --- a/modules/api/views.js +++ b/modules/api/views.js @@ -302,10 +302,18 @@ export default function(app) { var htmlArray = (html || "").match(/.{1,8191}/g) || ""; + // Emitted raw inside a " would break out of + // the script element (XSS). Escape "<" to its < JS escape, which + // is inert in HTML but decodes back to "<" in JS. + function jsonForScript(value) { + return JSON.stringify(value).replace(/