Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix(clapi): remove carriage returns from response
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Vassilev committed Jun 14, 2019
1 parent eb2ad05 commit 0a17227
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions www/api/class/centreon_clapi.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ public function postAction()
} else {
$return['result'][] = $lines[$i];
}

if (is_array($return['result'])) {
array_walk($return['result'], [$this, 'clearCarriageReturns']);
}
}
return $return;
}
Expand All @@ -230,4 +234,12 @@ public function authorize($action, $user, $isInternal = false)

return $user->hasAccessRestApiConfiguration();
}

/**
* Removes carriage returns from $item if string
* @param $item variable to check
*/
private function clearCarriageReturns(&$item) {
$item = (is_string($item)) ? str_replace(array("\n", "\t", "\r", "<br/>"), '', $item) : $item;
}
}

0 comments on commit 0a17227

Please sign in to comment.