From 780182d943decf62fab5a4f7c551eebd0b1fc5ed Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 3 Apr 2026 09:45:56 +0200 Subject: [PATCH] Bug 42253: Prevent XSS in the advanced editor - macros Test plan: /cgi-bin/koha/cataloguing/editor.pl Click "Macros", "New macro..." Enter 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 Signed-off-by: David Cook Signed-off-by: wainuiwitikapark --- koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc index a74a8aef11..a69f69d451 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc @@ -780,7 +780,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr 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 = { @@ -885,7 +885,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr $.ajax(options) .then(function(result) { $.each(result,function( undef, macro ){ - var $li = $( '
  • ' + macro.name + '
    1. ' ); + var $li = $( '
    2. ' + escape_str(macro.name) + '
      1. ' ); if ( macro.macro_id == macroEditor.activeMacroId ) $li.addClass( 'active' ); $li.click( function() { loadMacro(macro.name, macro.macro_id, macro.shared);