diff --git a/client/js/util/markdown.js b/client/js/util/markdown.js index e71e3263..2a1b2d0e 100644 --- a/client/js/util/markdown.js +++ b/client/js/util/markdown.js @@ -110,24 +110,22 @@ class StrikeThroughWrapper extends BaseMarkdownWrapper { } } -function createRenderer() { - function sanitize(str) { - return str.replace(/&<"/g, (m) => { - if (m === "&") { - return "&"; - } - if (m === "<") { - return "<"; - } - return """; - }); - } +function escapeHtml(unsafe) { + return unsafe + .toString() + .replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); +} +function createRenderer() { const renderer = new marked.Renderer(); renderer.image = (href, title, alt) => { let [_, url, width, height] = /^(.+?)(?:\s=\s*(\d*)\s*x\s*(\d*)\s*)?$/.exec(href); - let res = '' + sanitize(alt);
+        let res = '<img src=/g, ">") - .replace(/"/g, """) - .replace(/'/g, "'"); -} - function arraysDiffer(source1, source2, orderImportant) { source1 = [...source1]; source2 = [...source2]; @@ -221,7 +211,7 @@ module.exports = { enableExitConfirmation: enableExitConfirmation, disableExitConfirmation: disableExitConfirmation, confirmPageExit: confirmPageExit, - escapeHtml: escapeHtml, + escapeHtml: markdown.escapeHtml, makeCssName: makeCssName, splitByWhitespace: splitByWhitespace, arraysDiffer: arraysDiffer,