automatically trim() all parameters given

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2018-02-26 08:21:56 +01:00
parent 4a1decf359
commit 592c9ed0b9
6 changed files with 35 additions and 31 deletions

View File

@@ -106,6 +106,10 @@ abstract class ApiCommand
$this->version = $version;
$this->dbversion = $dbversion;
$this->branding = $branding;
if (! is_null($params)) {
$params = $this->trimArray($params);
}
$this->cmd_params = $params;
if (! empty($header)) {
$this->readUserData($header);
@@ -463,4 +467,15 @@ abstract class ApiCommand
}
throw new Exception("Invalid API credentials", 400);
}
private function trimArray($input)
{
if (! is_array($input)) {
return trim($input);
}
return array_map(array(
$this,
'trimArray'
), $input);
}
}