Repository navigation
Replace inline onClick/onChange handlers with jQuery bindings and cactiReturnTo class - #404
Conversation
…tiReturnTo class
Remove inline event-handler attributes in favor of unobtrusive jQuery handlers, matching the existing initSyslog* ready-block pattern:
- Filter selects (#rows/#refresh/#removal/#grouping/#enabled) drop onChange='applyFilter*()' and are bound via .change() in their init functions.
- The search filter toggle drops onclick='toggleSyslogSearch()' and binds #syslog_search_toggle via .click().
- The classic syslog_form_callback dropdown drops the inline onChange and binds through the existing whitelisted syslogInvokeCallback helper.
- Cancel/Return buttons drop onClick='cactiReturnTo()' and use the cactiReturnTo class the page JS already looks for (saveRow.find('.cactiReturnTo')).
There was a problem hiding this comment.
🟡 Changes recommended
The generated classic-dropdown binding remains an un-nonced inline script and is blocked by nonce-enforced CSP.
1 open finding
What changed in this PR
Replaces inline DOM event handlers with jQuery bindings and Cacti return-button classes to improve CSP compatibility.
Changes:
- Moves filter and search-toggle handlers into
js/functions.js. - Replaces inline cancel handlers with
cactiReturnTo. - Routes classic dropdown callbacks through the whitelist helper.
| File | Description |
|---|---|
js/functions.js |
Adds unobtrusive filter and toggle bindings. |
syslog.php |
Removes inline handlers and updates callback binding. |
syslog_alerts.php |
Updates filters and cancel button. |
syslog_dashboards.php |
Updates row filter and cancel button. |
syslog_device_rules.php |
Updates cancel button. |
syslog_removal.php |
Updates filters and cancel button. |
syslog_reports.php |
Updates filters and return buttons. |
syslog_saved_searches.php |
Updates row filter and cancel button. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Addresses CSP review feedback: the per-select inline <script> would be blocked under nonce-enforced CSP. Emit the whitelisted callback as a data-on-change attribute on the select and bind it with a delegated change handler in initSyslogMain(), which survives AJAX filter reloads.
|
Pushed Addressed: the classic-dropdown branch of CI note: the PHP 8.2 and 8.4 Integration Test failures are unrelated to this change — they failed in the Initialize containers step with Docker Hub |

Description
Removes all inline DOM event-handler attributes (
onClick/onChange/onclick/onChange) from the Syslog plugin pages and replaces them with unobtrusive jQuery bindings, plus the CacticactiReturnToclass.#rows,#refresh,#removal,#grouping,#enabled) no longer carryonChange='applyFilter*()'. They are bound with.change()inside the existinginitSyslog*()jQuery ready blocks injs/functions.js, alongside the handlers already registered there (#refresh,#clear,#import, form submit).onclick='toggleSyslogSearch()';#syslog_search_toggleis bound via.click()ininitSyslogMain().syslog_form_callback()): dropped the inlineonChangeand route the change through the existing whitelistedsyslogInvokeCallback()helper (the autocomplete branch already used it), keeping the server-provided callback identifier.syslog_alerts.php,syslog_dashboards.php,syslog_device_rules.php,syslog_removal.php,syslog_reports.php,syslog_saved_searches.php) droponClick='cactiReturnTo()'and use thecactiReturnToclass that the page JS already queries (saveRow.find('.cactiReturnTo')).Motivation and Context
Inline event-handler attributes require
script-src 'unsafe-inline'and conflict with a strict Content-Security-Policy. Moving them to jQuery bindings and thecactiReturnToclass aligns these pages with Cacti core conventions and the handler bindings already present in this plugin, with no change to user-visible behavior.How Has This Been Tested?
php -lpasses on every modified PHP file.on*=handler attributes remain in production PHP (tests excluded).js/functions.jsfunction names referenced by unit tests are unchanged.Types of changes
Checklist: