From e2777c6591a0fba36b03e183c49168db8205b3fe Mon Sep 17 00:00:00 2001 From: npt-1707 Date: Mon, 11 May 2026 07:26:41 +0700 Subject: [PATCH] static/rest_framework_swagger/lib/marked.js: added explicit matching for HTML entities to prevent XSS --- static/rest_framework_swagger/lib/marked.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/static/rest_framework_swagger/lib/marked.js b/static/rest_framework_swagger/lib/marked.js index c2a678d5..f2b1521e 100644 --- a/static/rest_framework_swagger/lib/marked.js +++ b/static/rest_framework_swagger/lib/marked.js @@ -1083,7 +1083,8 @@ function escape(html, encode) { } function unescape(html) { - return html.replace(/&([#\w]+);/g, function(_, n) { + // explicitly match decimal, hex, and named HTML entities + return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(\w+))/g, function(_, n) { n = n.toLowerCase(); if (n === 'colon') return ':'; if (n.charAt(0) === '#') {