diff --git a/CHANGELOG.md b/CHANGELOG.md index 71714cd4..bb9ed47c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Added + +- Make the plugin compatible with the Content Security Policy + ### Fixed - Fix the uploaded file name being lost after the client injection upload step diff --git a/inc/info.class.php b/inc/info.class.php index 899eb3dc..7d034649 100644 --- a/inc/info.class.php +++ b/inc/info.class.php @@ -206,10 +206,10 @@ public static function showFormInfos(PluginDatainjectionModel $model) echo ""; echo sprintf("", $arrow); echo ""; - echo sprintf("", $formname) . __s('Check all') . ""; + echo sprintf("", htmlescape($formname)) . __s('Check all') . ""; echo "/"; echo ""; - echo sprintf("", $formname) . __s('Uncheck all') . ""; + echo sprintf("", htmlescape($formname)) . __s('Uncheck all') . ""; echo ""; echo ""; - echo "" . __s('Close') . ""; + echo "" . __s('Close') . ""; echo ""; } diff --git a/public/js/datainjection.js b/public/js/datainjection.js index 15893c8a..b1cad457 100644 --- a/public/js/datainjection.js +++ b/public/js/datainjection.js @@ -39,3 +39,44 @@ function show_log(num) { document.getElementById('log'+num+'_table').style.display = 'none'; } } + +document.addEventListener('click', (e) => { + const markLink = e.target.closest('[data-datainjection-mark-checkboxes]'); + if (markLink !== null) { + if (markCheckboxes(markLink.dataset.datainjectionMarkCheckboxes)) { + e.preventDefault(); + } + return; + } + + const unmarkLink = e.target.closest('[data-datainjection-unmark-checkboxes]'); + if (unmarkLink !== null) { + if (unMarkCheckboxes(unmarkLink.dataset.datainjectionUnmarkCheckboxes)) { + e.preventDefault(); + } + return; + } + + const popupLink = e.target.closest('[data-datainjection-popup]'); + if (popupLink !== null) { + const popup = window.open( + popupLink.dataset.datainjectionPopup, + 'glpipopup', + popupLink.dataset.datainjectionPopupFeatures + ); + popup.focus(); + e.preventDefault(); + return; + } + + const locationLink = e.target.closest('[data-datainjection-location]'); + if (locationLink !== null) { + location.href = locationLink.dataset.datainjectionLocation; + return; + } + + if (e.target.closest('[data-datainjection-close-window]') !== null) { + e.preventDefault(); + window.close(); + } +}); diff --git a/setup.php b/setup.php index b411fa92..43b028d6 100644 --- a/setup.php +++ b/setup.php @@ -98,6 +98,7 @@ function plugin_version_datainjection() 'homepage' => 'https://github.com/pluginsGLPI/datainjection', 'license' => 'GPLv2+', 'version' => PLUGIN_DATAINJECTION_VERSION, + 'csp_compliant' => true, 'requirements' => [ 'glpi' => [ 'min' => PLUGIN_DATAINJECTION_MIN_GLPI, diff --git a/templates/clientinjection_result.html.twig b/templates/clientinjection_result.html.twig index 15ca3f22..fabf3638 100644 --- a/templates/clientinjection_result.html.twig +++ b/templates/clientinjection_result.html.twig @@ -44,18 +44,18 @@
- +

{% if has_pdf %} - +

{% endif %} {% if has_errors %} - +

{% endif %} diff --git a/templates/clientinjection_upload_file.html.twig b/templates/clientinjection_upload_file.html.twig index 43ffaa20..7f261576 100644 --- a/templates/clientinjection_upload_file.html.twig +++ b/templates/clientinjection_upload_file.html.twig @@ -69,7 +69,7 @@ {% else %} {% set message = __("Watch out, you're about to inject data into GLPI. Are you sure you want to do it ?", 'datainjection') %} {% endif %} - + {% else %} {% endif %} diff --git a/templates/log_results.html.twig b/templates/log_results.html.twig index 0a8fd8f2..9985986a 100644 --- a/templates/log_results.html.twig +++ b/templates/log_results.html.twig @@ -141,6 +141,6 @@ {% endif %}
- {{ __('Close') }} +
\ No newline at end of file diff --git a/templates/mappings_form.html.twig b/templates/mappings_form.html.twig index 1063f0e0..bb76a021 100644 --- a/templates/mappings_form.html.twig +++ b/templates/mappings_form.html.twig @@ -32,7 +32,7 @@
- + {{ __('See the file', 'datainjection') }}