Skip to content

Node.js based forum software built for the modern web

fix: improper neutralization of user input in image wrapping code

Julian Lam1d1639d46f15
diff --git a/public/src/client/topic/images.js b/public/src/client/topic/images.js
index 8778053821..c4c30319d8 100644
--- a/public/src/client/topic/images.js
+++ b/public/src/client/topic/images.js
@@ -26,8 +26,9 @@ define('forum/topic/images', [], function () {
const srcExt = src.split('.').slice(1).pop();
const altFilename = alt.split('/').pop();
const altExt = altFilename.split('.').slice(1).pop();
+
imageEl.wrap('<a href="' + src + '" ' +
- (!srcExt && altExt ? ' download="' + altFilename + '" ' : '') +
+ (!srcExt && altExt ? ' download="' + utils.escapeHTML(altFilename) + '" ' : '') +
' target="_blank" rel="noopener">');
}
};