Skip to content

fix(ui): massive actions failing for plugins with namespaces - #25049

Open
eduardomozart wants to merge 3 commits into
glpi-project:11.0/bugfixesfrom
eduardomozart:fix-issue-22614
Open

fix(ui): massive actions failing for plugins with namespaces#25049
eduardomozart wants to merge 3 commits into
glpi-project:11.0/bugfixesfrom
eduardomozart:fix-issue-22614

Conversation

@eduardomozart

Copy link
Copy Markdown
Contributor

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

Closes #22614.

When plugins use namespaces for their classes (e.g., GlpiPlugin\Samlsso\RuleSamlCollection), the generated container ID includes backslashes. When this ID is used in an inline JavaScript snippet to generate a jQuery selector, the single backslash evaluates properly as a JavaScript string literal, but fails when evaluated by jQuery's CSS selector engine. CSS requires literal backslashes to be double-escaped \\.

This PR ensures that container IDs used in inline jQuery selectors within Html.php explicitly have their backslashes escaped for CSS (by passing the string through addcslashes($container_id, '\\') prior to jsescape()). This correctly emits four backslashes \\\\ into the JavaScript string literal, which evaluates to a double backslash \\ in JavaScript, allowing jQuery to properly target the element ID.

  • Fixed Html::getCheckAllAsCheckbox()
  • Fixed Html::getCheckboxesFilter()
  • Fixed Html::showMassiveActionsBlock()
  • Added test coverage in HtmlTest::testMassiveActionContainerIdEscaping

Screenshots (if appropriate):

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.

Plugin rules massive action fails because of JS escape

1 participant