diff --git a/inc/common.class.php b/inc/common.class.php
index e13e478e..3e5d7d24 100644
--- a/inc/common.class.php
+++ b/inc/common.class.php
@@ -1018,7 +1018,7 @@ public static function showGraphDatas(
echo "
";
echo '| ' . htmlspecialchars($label2) . ' | ';
if ($simpledatas) { //simple array
- echo "" . htmlspecialchars($cols) . ' ' . htmlspecialchars($unit) . ' | ';
+ echo "" . htmlspecialchars($cols) . ' ' . htmlspecialchars($unit ?? '') . ' | ';
} else { //multiple array
foreach ($cols as $date => $nb) {
if (!is_array($nb)) {
diff --git a/inc/graph.class.php b/inc/graph.class.php
index 54a84e7a..43b269ad 100644
--- a/inc/graph.class.php
+++ b/inc/graph.class.php
@@ -60,7 +60,7 @@ public function initGraph($options)
echo "";
$gtype = htmlspecialchars($_REQUEST['gtype']);
- echo "

";
+ echo "

";
echo htmlspecialchars($options['title']);
echo '
';
@@ -105,7 +105,10 @@ public function initGraph($options)
echo "";
- $colors = htmlspecialchars("'" . implode("', '", PluginMreportingConfig::getColors()) . "'");
+
+ $colorsArray = PluginMreportingConfig::getColors();
+ $escapedColors = array_map(fn($color) => htmlspecialchars($color, ENT_QUOTES, 'UTF-8'), $colorsArray);
+ $colors = "'" . implode("', '", $escapedColors) . "'";
echo "