Skip to content

Commit

Permalink
Update grid_lsdashboard.php to support '+' in 'Service Domain' filter…
Browse files Browse the repository at this point in the history
… field

  platformcomputing/lsf-addon-L3-tracker#433
  • Loading branch information
Jing Chen committed Sep 1, 2022
1 parent 63c7d8e commit ba6a131
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
22 changes: 22 additions & 0 deletions cacti/lib/rtm_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,28 @@ function resource_sanitize_search_string($string) {
return $string;
}

// Ref cacti sanitize_search_string(), exclude '+'.
function rtm_filter_sanitize_search_string($string) {
static $drop_char_match = array('(',')','^', '$', '<', '>', '`', '\'', '"', '|', ',', '?', '[', ']', '{', '}', '#', ';', '!', '=', '*');
static $drop_char_replace = array('','',' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');

/* Replace line endings by a space */
$string = preg_replace('/[\n\r]/is', ' ', $string);

/* HTML entities like &nbsp; */
$string = preg_replace('/\b&[a-z]+;\b/', ' ', $string);

/* Remove URL's */
$string = preg_replace('/\b[a-z0-9]+:\/\/[a-z0-9\.\-]+(\/[a-z0-9\?\.%_\-\+=&\/]+)?/', ' ', $string);

/* Filter out strange characters like ^, $, &, change "it's" to "its" */
for($i = 0; $i < cacti_count($drop_char_match); $i++) {
$string = str_replace($drop_char_match[$i], $drop_char_replace[$i], $string);
}

return $string;
}

function rtm_sanitize_unserialize_selected_items($items, $checkvalue = true) {
if ($items != '') {
$unstripped = stripslashes($items);
Expand Down
5 changes: 3 additions & 2 deletions cacti/plugins/gridblstat/grid_lsdashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
include($config['base_path'] . '/lib/rrd.php');
include($config['base_path'] . '/lib/timespan_settings.php');
include($config['base_path'] . '/plugins/gridblstat/lib/functions.php');
include_once($config['library_path'] . '/rtm_functions.php');

$title = __('IBM Spectrum LSF RTM - License Scheduler Dashboard', 'gridblstat');

Expand Down Expand Up @@ -739,7 +740,7 @@ function drawChart(id_number, graph,shift) {
'filter' => FILTER_CALLBACK,
'pageset' => true,
'default' => '',
'options' => array('options' => 'sanitize_search_string')
'options' => array('options' => 'rtm_filter_sanitize_search_string')
),
'sort_column' => array(
'filter' => FILTER_CALLBACK,
Expand Down Expand Up @@ -1353,7 +1354,7 @@ function applyFilter() {
strURL += '&region=' + $('#region').val();
strURL += '&rows=' + $('#rows').val();
strURL += '&level=' + $('#level').val();
strURL += '&sd=' + $('#sd').val();
strURL += '&sd=' + encodeURIComponent($('#sd').val());
strURL += '&inuse=' + $('#inuse').is(':checked');
strURL += '&refresh=' + $('#refresh').val();
loadPageNoHeader(strURL);
Expand Down

0 comments on commit ba6a131

Please sign in to comment.