diff --git a/CHANGELOG.md b/CHANGELOG.md index cce3f19..0ef0094 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Changelog --- develop --- +* security: Move the map region navigation's 'Start Over' and 'Print' buttons from inline `onclick` handlers to delegated jQuery bindings in `js/GPSMaps.js` (via `gpsmapStartOver`/`gpsmapPrint` classes) so the map no longer trips Cacti's Content-Security-Policy script-src-attr directive * dev: Replace the translation-template CI check that regenerated locales/po/cacti.pot and compared it with a diff-based gate (tests/bin/check-i18n-pot.php) requiring cacti.pot to be updated only when a pull request adds, removes, or modifies an i18n function call * refactor: Switch every file inclusion from include/include_once to require/require_once for fail-fast consistency (schema already lives in includes/setup/database.php via the plugin table API, so no schema changes were needed) * dev: Measure CI coverage with xdebug instead of pcov so the plugin's own sources are instrumented (pcov auto-scopes to the Composer root and skipped cacti/plugins/, leaving the patch-coverage gate with nothing to measure) diff --git a/includes/polling/processregion.php b/includes/polling/processregion.php index 9a32250..1b01e63 100644 --- a/includes/polling/processregion.php +++ b/includes/polling/processregion.php @@ -527,8 +527,8 @@ function gpsmap_render_region(array $hostArrays, string $subnet, ?GpsmapPollStat // print out the information we have gathered. $body .= '
'; - $body .= '
'; - $body .= ''; + $body .= '
'; + $body .= ''; $body .= '
'; // six links per column block diff --git a/js/GPSMaps.js b/js/GPSMaps.js index 92bd3e2..017091c 100644 --- a/js/GPSMaps.js +++ b/js/GPSMaps.js @@ -359,3 +359,17 @@ var gpsmap = { } } }; + +$(function() { + $(document).off('click.gpsmapNav', '.gpsmapStartOver') + .on('click.gpsmapNav', '.gpsmapStartOver', function(event) { + event.preventDefault(); + window.location.reload(true); + }); + + $(document).off('click.gpsmapNav', '.gpsmapPrint') + .on('click.gpsmapNav', '.gpsmapPrint', function(event) { + event.preventDefault(); + window.open('print.php'); + }); +}); diff --git a/tests/Integration/RegionMenuCspTest.php b/tests/Integration/RegionMenuCspTest.php new file mode 100644 index 0000000..673d61f --- /dev/null +++ b/tests/Integration/RegionMenuCspTest.php @@ -0,0 +1,39 @@ +toBeTrue(); + + $menu = file_get_contents($root . '/plugins/gpsmap/XML/198.51.100-top.html'); + + expect($menu)->toContain('class="gpsmapStartOver"'); + expect($menu)->toContain('class="print gpsmapPrint"'); + expect($menu)->not->toContain('onclick'); +});