Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions modules/api/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,18 @@ export default function(app) {

var htmlArray = (html || "").match(/.{1,8191}/g) || "";

// Emitted raw inside a <script> in readerjs.ejs. JSON.stringify does
// not escape "<", so a value containing "</script>" 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(/</g, '\\u003c');
}

var context = {
embedCode: JSON.stringify(htmlArray),
embedCode: jsonForScript(htmlArray),
widgetId: JSON.stringify(1),
uri: JSON.stringify(uri)
uri: jsonForScript(uri)
};

res.renderCached("readerjs.ejs", context, {
Expand Down
Loading