Skip to content

[main] feat: make plugin CSP compliant - #258

Merged
jdurand-teclib merged 1 commit into
mainfrom
forward-port/255-to-main
Nov 25, 2026
Merged

jdurand-teclib merged 1 commit into
mainfrom
forward-port/255-to-main

Conversation

@glpi-project

@glpi-project glpi-project Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Forward-port of #255 to main.

Description

The plugin now declares csp_compliant and no longer relies on inline event handlers, so it keeps working when GLPI sends its Content Security Policy.

Converted patterns:

  • templates/view.html.twig: fullscreen button onclick="gantt.ext.fullscreen.toggle();" replaced by the data-gantt-fullscreen attribute (category a).
  • templates/view.html.twig: search field oninput="gantt.$doFilter(this.value);" replaced by the data-gantt-filter attribute (category a).
  • public/js/gantt-helper.js: two delegated listeners bound once at file load, calling the same functions with the same arguments.
  • setup.php: 'csp_compliant' => true added to plugin_version_gantt().

No <script> tag was printed from PHP or created from JavaScript: the only inline script is literal Twig text and receives the nonce automatically.

No behaviour change.

Blocked by

Manual test checklist

Open a project with the Gantt tab (Project item, Gantt tab) and keep the browser console open. CSP violations are reported there as Refused to execute inline event handler or Refused to execute inline script.

  • Click the fullscreen button (icon at the top right of the Gantt controls): the Gantt enters and leaves fullscreen mode.
  • Type in the "by name" search field with the Find option selected: matching tasks are highlighted and the view refreshes about 500 ms after typing stops.
  • Type in the same field with the Filter option selected: only matching tasks are displayed.
  • No CSP error appears in the console.

@glpi-project

glpi-project Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin forward-port/255-to-main
git worktree add --checkout .worktree/forward-port/255-to-main forward-port/255-to-main
cd .worktree/forward-port/255-to-main
git reset --hard HEAD^
git cherry-pick -x 287e845eb7c9430099bc5bc9219be90addccb3f3

@Rom1-B
Rom1-B force-pushed the forward-port/255-to-main branch from 346b226 to e08f937 Compare November 24, 2026 09:02
@Rom1-B
Rom1-B marked this pull request as ready for review November 24, 2026 10:54
@Rom1-B
Rom1-B requested review from a team, Mary-Clb, Rom1-B and jdurand-teclib and removed request for a team November 24, 2026 10:54
@jdurand-teclib
jdurand-teclib merged commit f31c46e into main Nov 25, 2026
7 checks passed
@jdurand-teclib
jdurand-teclib deleted the forward-port/255-to-main branch November 25, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants