Bug 42253: Prevent XSS in the advanced editor - macros

Test plan:
/cgi-bin/koha/cataloguing/editor.pl
Click "Macros", "New macro..."
Enter <script>alert("booh");</script>
OK
Click on the macro name, run macro, delete macro, mark as public:
Nothing should trigger an alert

QA:
-            $( '#macro-list li[data-name="' + name + '"][data-id="' + id + '"]' ).addClass( 'active' );
+            $( '#macro-list li[data-id="' + id + '"]' ).addClass( 'active' );
Why did we need name and id to select the macro?

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
Jonathan Druart 2026-04-03 09:45:56 +02:00 committed by Jacob O'Mara
parent ba6872eb2e
commit 7c58c8183e
No known key found for this signature in database
1 changed files with 2 additions and 2 deletions

View File

@ -773,7 +773,7 @@
macroEditor.setValue( '' );
return;
}
$( '#macro-list li[data-name="' + name + '"][data-id="' + id + '"]' ).addClass( 'active' );
$( '#macro-list li[data-id="' + id + '"]' ).addClass( 'active' );
api_url = "/api/v1/advanced_editor/macros/";
if( shared ) { api_url += "shared/" }
let options = {
@ -878,7 +878,7 @@
$.ajax(options)
.then(function(result) {
$.each(result,function( undef, macro ){
var $li = $( '<li data-name="' + macro.name + '" data-id="' + macro.macro_id + '"><a href="#">' + macro.name + '</a><ol class="macro-info"></ol></li>' );
var $li = $( '<li data-name="' + escape_str(macro.name) + '" data-id="' + macro.macro_id + '"><a href="#">' + escape_str(macro.name) + '</a><ol class="macro-info"></ol></li>' );
if ( macro.macro_id == macroEditor.activeMacroId ) $li.addClass( 'active' );
$li.click( function() {
loadMacro(macro.name, macro.macro_id, macro.shared);