diff --git a/cli/cacti-mapper.php b/cli/cacti-mapper.php index c73bd25..1346751 100644 --- a/cli/cacti-mapper.php +++ b/cli/cacti-mapper.php @@ -147,7 +147,7 @@ unset($interfaces[$key]); $cleaned++; } else { - $interfaces[$key]['nicename'] = (isset($int['name']) ? $int['name'] : (isset($int['descr']) ? $int['descr'] : (isset($int['alias']) ? $int['alias'] : 'Interface #' . $int['index']))); + $interfaces[$key]['nicename'] = ($int['name'] ?? ($int['descr'] ?? ($int['alias'] ?? 'Interface #' . $int['index']))); } } } diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..37b0c2d --- /dev/null +++ b/composer.json @@ -0,0 +1,18 @@ +{ + "name": "cacti/plugin_weathermap", + "description": "plugin_weathermap plugin for Cacti", + "license": "GPL-2.0-or-later", + "require-dev": { + "pestphp/pest": "^1.23" + }, + "config": { + "allow-plugins": { + "pestphp/pest-plugin": true + } + }, + "autoload-dev": { + "files": [ + "tests/bootstrap.php" + ] + } +} diff --git a/js/editor.js b/js/editor.js index 7a22f0f..0c48bcf 100644 --- a/js/editor.js +++ b/js/editor.js @@ -1,4 +1,11 @@ // global variable for subwindow reference +// Escape HTML special characters to prevent XSS +function escapeHtml(str) { + if (typeof str !== 'string') return ''; + return str.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); +} + + const MESSAGE_LEVEL_NONE = 0; const MESSAGE_LEVEL_INFO = 1; const MESSAGE_LEVEL_WARN = 2; @@ -1050,11 +1057,11 @@ function prime_link_form(name) { // if that didn't 'stick', then we need to add the special value if ($('#link_commentposout').val() != mylink.commentposout) { - $('#link_commentposout').prepend(""); + $('#link_commentposout').prepend($('"); + $('#link_commentposin').prepend($('