@@ -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, "<" )
278+ . replace ( / > / g, ">" )
279+ . replace ( / " / g, """ )
280+ . replace ( / ' / g, "'" ) ;
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