mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
IcingaConfigHelper: do not quote safe keys
Why? It looks better. Sex sells, you know. And Rune asked for it. Additionally, we now write empty dictionaries on a single line fixes #12447
This commit is contained in:
parent
601e182b15
commit
9750d4f637
@ -103,6 +103,15 @@ class IcingaConfigHelper
|
||||
return '"' . $string . '"';
|
||||
}
|
||||
|
||||
public static function renderDictionaryKey($key)
|
||||
{
|
||||
if (preg_match('/^[a-z0-9_]+\d*$/i', $key)) {
|
||||
return static::escapeIfReserved($key);
|
||||
} else {
|
||||
return static::renderString($key);
|
||||
}
|
||||
}
|
||||
|
||||
// Requires an array
|
||||
public static function renderArray($array)
|
||||
{
|
||||
@ -129,7 +138,16 @@ class IcingaConfigHelper
|
||||
{
|
||||
$vals = array();
|
||||
foreach ($dictionary as $key => $value) {
|
||||
$vals[$key] = rtrim(self::renderKeyValue(self::renderString($key), $value));
|
||||
$vals[$key] = rtrim(
|
||||
self::renderKeyValue(
|
||||
self::renderDictionaryKey($key),
|
||||
$value
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($vals)) {
|
||||
return '{}';
|
||||
}
|
||||
ksort($vals);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user