Merge branch 'ent-7079-escapar-caracters-url-api' into 'develop'

Addded param to escape API url call raw_decode

See merge request artica/pandorafms!3914
This commit is contained in:
Daniel Rodriguez 2021-04-07 10:54:47 +00:00
commit 517d7378d4
2 changed files with 8 additions and 6 deletions

View File

@ -55,8 +55,9 @@ $api_password = get_parameter('apipass', '');
$password = get_parameter('pass', ''); $password = get_parameter('pass', '');
$user = get_parameter('user', ''); $user = get_parameter('user', '');
$info = get_parameter('info', ''); $info = get_parameter('info', '');
$raw_decode = (bool) get_parameter('raw_decode', false);
$other = parseOtherParameter($otherSerialize, $otherMode); $other = parseOtherParameter($otherSerialize, $otherMode, $raw_decode);
$apiPassword = io_output_password( $apiPassword = io_output_password(
db_get_value_filter( db_get_value_filter(
'value', 'value',

View File

@ -43,11 +43,12 @@ use PandoraFMS\Enterprise\Cluster;
/** /**
* Parse the "other" parameter. * Parse the "other" parameter.
* *
* @param string $other * @param string $other
* @param mixed $otherType * @param mixed $otherType
* @param boolean $rawDecode Decode string in which the sequences with percent (%) signs followed by two hex digits have been replaced with literal characters.
* @return mixed * @return mixed
*/ */
function parseOtherParameter($other, $otherType) function parseOtherParameter($other, $otherType, $rawDecode)
{ {
switch ($otherType) { switch ($otherType) {
case 'url_encode': case 'url_encode':
@ -65,12 +66,12 @@ function parseOtherParameter($other, $otherType)
'data' => explode($separator, $other), 'data' => explode($separator, $other),
]; ];
foreach ($returnVar['data'] as $index => $element) { foreach ($returnVar['data'] as $index => $element) {
$returnVar['data'][$index] = urldecode($element); $returnVar['data'][$index] = $rawDecode ? rawurldecode($element) : urldecode($element);
} }
} else { } else {
$returnVar = [ $returnVar = [
'type' => 'string', 'type' => 'string',
'data' => urldecode($other), 'data' => $rawDecode ? rawurldecode($other) : urldecode($other),
]; ];
} }
break; break;