Repository navigation
feat: make plugin CSP compliant - #255
Merged
Merged
Conversation
Rom1-B
marked this pull request as ready for review
November 19, 2026 10:05
Rom1-B
requested review from
a team,
Herafia,
Lainow and
jdurand-teclib
and removed request for
a team
November 19, 2026 10:05
jdurand-teclib
approved these changes
Nov 20, 2026
Herafia
approved these changes
Nov 20, 2026
Contributor
|
Backport-action backported this pull request in workflow run 44747507646.
|
Rom1-B
added a commit
that referenced
this pull request
Nov 24, 2026
jdurand-teclib
pushed a commit
that referenced
this pull request
Nov 25, 2026
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 - glpi-project/glpi#26020 (CSP) and its 11.0 / 12.0 backports: the minimum GLPI version (`PLUGIN_GANTT_MIN_GLPI_VERSION`, currently 11.0.0) must be bumped to the first CSP-enabled release before merging. ## 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. Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The plugin now declares
csp_compliantand 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 buttononclick="gantt.ext.fullscreen.toggle();"replaced by thedata-gantt-fullscreenattribute (category a).templates/view.html.twig: search fieldoninput="gantt.$doFilter(this.value);"replaced by thedata-gantt-filterattribute (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' => trueadded toplugin_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
PLUGIN_GANTT_MIN_GLPI_VERSION, currently 11.0.0) must be bumped to the first CSP-enabled release before merging.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 handlerorRefused to execute inline script.