From 0a17227f74b2eb76e051f9fb84e92df12da154d8 Mon Sep 17 00:00:00 2001 From: Victor Vassilev Date: Fri, 14 Jun 2019 10:24:09 +0300 Subject: [PATCH] fix(clapi): remove carriage returns from response --- www/api/class/centreon_clapi.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/www/api/class/centreon_clapi.class.php b/www/api/class/centreon_clapi.class.php index d462fa9f2bb..66f0daea5e9 100644 --- a/www/api/class/centreon_clapi.class.php +++ b/www/api/class/centreon_clapi.class.php @@ -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; } @@ -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", "
"), '', $item) : $item; + } }