From e9e9f91fee6df668f0f1fcb60facd8fb5c0cff74 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 16 Jun 2015 17:54:38 +0200 Subject: [PATCH] IcingaConfigHelper: Use config renderer and escape strings --- .../Director/IcingaConfig/IcingaConfigHelper.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/library/Director/IcingaConfig/IcingaConfigHelper.php b/library/Director/IcingaConfig/IcingaConfigHelper.php index 59e870d6..ea2cd1f8 100644 --- a/library/Director/IcingaConfig/IcingaConfigHelper.php +++ b/library/Director/IcingaConfig/IcingaConfigHelper.php @@ -92,17 +92,25 @@ class IcingaConfigHelper return '"' . $string . '"'; } - // Requires an array of CustomVariable objects + // Requires an array public static function renderArray($array) { - $str = '[ ' . implode(', ', $array) . ' ]'; + $data = array(); + foreach ($array as $entry) { + if ($entry instanceof IcingaConfigRenderer) { + $data[] = $entry; + } else { + $data[] = self::renderString($entry); + } + } + $str = '[ ' . implode(', ', $data) . ' ]'; if (strlen($str) < 60) { return $str; } // Prefix for toConfigString? - return "[\n " . implode(",\n ", $array) . "\n]"; + return "[\n " . implode(",\n ", $data) . "\n]"; }