@@ -60,7 +60,7 @@ public function initGraph($options)
6060 echo "<div class='graph_title'> " ;
6161 $ gtype = htmlspecialchars ($ _REQUEST ['gtype ' ]);
6262
63- echo "<img src=' " . $ CFG_GLPI ['root_doc ' ] . "' /plugins/mreporting/pics/chart-$ gtype.png' class='title_pics' /> " ;
63+ echo "<img src=' " . $ CFG_GLPI ['root_doc ' ] . "/plugins/mreporting/pics/chart- $ gtype.png' class='title_pics' /> " ;
6464 echo htmlspecialchars ($ options ['title ' ]);
6565 echo '</div> ' ;
6666
@@ -105,7 +105,10 @@ public function initGraph($options)
105105
106106 echo "<div class='graph' id='graph_content " . $ randname . "'> " ;
107107
108- $ colors = htmlspecialchars ("' " . implode ("', ' " , PluginMreportingConfig::getColors ()) . "' " );
108+
109+ $ colorsArray = PluginMreportingConfig::getColors ();
110+ $ escapedColors = array_map (fn ($ color ) => htmlspecialchars ($ color , ENT_QUOTES , 'UTF-8 ' ), $ colorsArray );
111+ $ colors = "' " . implode ("', ' " , $ escapedColors ) . "' " ;
109112 echo "<script type='text/javascript+protovis'>
110113 showGraph $ randname = function() {
111114 colors = pv.colors( $ colors); " ;
@@ -299,7 +302,7 @@ public function showHbar($params, $dashboard = false, $width = false)
299302JAVASCRIPT ;
300303
301304 if ($ show_graph ) {
302- echo htmlspecialchars ( $ JS ) ;
305+ echo $ JS ;
303306 }
304307
305308 $ opt ['randname ' ] = $ randname ;
@@ -496,7 +499,7 @@ public function showPie($params, $dashboard = false, $width = false)
496499JAVASCRIPT ;
497500
498501 if ($ show_graph ) {
499- echo htmlspecialchars ( $ JS ) ;
502+ echo $ JS ;
500503 }
501504
502505 $ opt ['randname ' ] = $ randname ;
@@ -776,7 +779,7 @@ function getLevelNbNode(node) {
776779JAVASCRIPT ;
777780
778781 if ($ show_graph ) {
779- echo htmlspecialchars ( $ JS ) ;
782+ echo $ JS ;
780783 }
781784
782785 $ opt ['randname ' ] = $ randname ;
@@ -1008,7 +1011,7 @@ public function showHgbar($params, $dashboard = false, $width = false)
10081011JAVASCRIPT ;
10091012
10101013 if ($ show_graph ) {
1011- echo htmlspecialchars ( $ JS ) ;
1014+ echo $ JS ;
10121015 }
10131016
10141017 $ opt ['randname ' ] = $ randname ;
@@ -1244,7 +1247,7 @@ public function showVstackbar($params, $dashboard = false, $width = false)
12441247JAVASCRIPT ;
12451248
12461249 if ($ show_graph ) {
1247- echo htmlspecialchars ( $ JS ) ;
1250+ echo $ JS ;
12481251 }
12491252
12501253 $ opt ['randname ' ] = $ randname ;
@@ -1485,7 +1488,7 @@ public function showArea($params, $dashboard = false, $width = false)
14851488JAVASCRIPT ;
14861489
14871490 if ($ show_graph ) {
1488- echo htmlspecialchars ( $ JS ) ;
1491+ echo $ JS ;
14891492 }
14901493
14911494 $ opt ['randname ' ] = $ randname ;
@@ -1765,7 +1768,7 @@ public function showGarea($params, $dashboard = false, $width = false)
17651768JAVASCRIPT ;
17661769
17671770 if ($ show_graph ) {
1768- echo htmlspecialchars ( $ JS ) ;
1771+ echo $ JS ;
17691772 }
17701773
17711774 $ opt ['randname ' ] = $ randname ;
0 commit comments