Skip to content

Commit b9070f1

Browse files
authored
Merge branch 'main' into ITEP-83030/renovate-config
2 parents 1a478d5 + 60ffbf3 commit b9070f1

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

manager/src/static/js/model_list.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,16 @@ $(document).ready(function () {
270270
$elements.detach().appendTo($container);
271271
}
272272

273+
// Helper function to escape HTML special characters
274+
function escapeHTML(str) {
275+
return String(str)
276+
.replace(/&/g, "&")
277+
.replace(/</g, "&lt;")
278+
.replace(/>/g, "&gt;")
279+
.replace(/"/g, "&quot;")
280+
.replace(/'/g, "&#39;");
281+
}
282+
273283
// Function to show the prompt modal to confirm the action
274284
function showModelPromptModal(action, path, filenames) {
275285
return new Promise((resolve, reject) => {
@@ -284,7 +294,7 @@ $(document).ready(function () {
284294
// Multiple files to overwrite/delete -> join with <br> for better readability
285295
if (Array.isArray(filenames)) {
286296
if (filenames.length > 0) {
287-
filenames = filenames.join("<br>");
297+
filenames = filenames.map(escapeHTML).join("<br>");
288298
}
289299
// No files to overwrite/delete -> no need prompt
290300
else {
@@ -297,7 +307,7 @@ $(document).ready(function () {
297307
}
298308
// Single file to overwrite/delete -> convert to string
299309
else {
300-
filenames = filenames.toString();
310+
filenames = escapeHTML(filenames.toString());
301311
}
302312

303313
// Set the path to "root" if it is empty

0 commit comments

Comments
 (0)