Skip to content

Commit

Permalink
webui: Stop stripping html tags from snmp creds (#7951)
Browse files Browse the repository at this point in the history
  • Loading branch information
laf authored and murrant committed Dec 25, 2017
1 parent f75079a commit 27368a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 5 additions & 5 deletions html/pages/addhost.inc.php
Expand Up @@ -52,19 +52,19 @@
);
} elseif ($_POST['snmpver'] === 'v2c' || $_POST['snmpver'] === 'v1') {
if ($_POST['community']) {
$config['snmp']['community'] = array(clean($_POST['community']));
$config['snmp']['community'] = array(clean($_POST['community'], false));
}

$snmpver = clean($_POST['snmpver']);
print_message("Adding host $hostname communit".(count($config['snmp']['community']) == 1 ? 'y' : 'ies').' '.implode(', ', $config['snmp']['community'])." port $port using $transport");
} elseif ($_POST['snmpver'] === 'v3') {
$v3 = array(
'authlevel' => clean($_POST['authlevel']),
'authname' => clean($_POST['authname']),
'authpass' => clean($_POST['authpass']),
'authname' => clean($_POST['authname'], false),
'authpass' => clean($_POST['authpass'], false),
'authalgo' => clean($_POST['authalgo']),
'cryptopass' => clean($_POST['cryptopass']),
'cryptoalgo' => clean($_POST['cryptoalgo']),
'cryptopass' => clean($_POST['cryptopass'], false),
'cryptoalgo' => clean($_POST['cryptoalgo'], false),
);

array_push($config['snmp']['v3'], $v3);
Expand Down
9 changes: 7 additions & 2 deletions includes/common.php
Expand Up @@ -1513,11 +1513,16 @@ function print_list($list, $format, $max = 10)

/**
* @param $value
* @param bool $strip_tags
* @return string
*/
function clean($value)
function clean($value, $strip_tags = true)
{
return strip_tags(mres($value));
if ($strip_tags === true) {
return strip_tags(mres($value));
} else {
return mres($value);
}
}

/**
Expand Down

0 comments on commit 27368a2

Please sign in to comment.