Skip to content

Commit a5a401f

Browse files
authored
Merge pull request #210 from Icinga:fix/escape_strings_in_array_dsl_properly
Fixes DSL for building array elements escaped Updates the Icinga DSL for building PowerShell arrays to ensure all string values are properly escaped with `'`. In case the user already wrapped commands with `'` by himself, this will not have an effect as we only add single quotes for escaping if they are not present already.
2 parents 0893325 + 742d7e0 commit a5a401f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Diff for: doc/31-Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1919
* [#203](https://github.com/Icinga/icinga-powershell-framework/pull/203) Removes experimental state of the Icinga PowerShell Framework code caching and adds docs on how to use the feature
2020
* [#205](https://github.com/Icinga/icinga-powershell-framework/pull/205) Ensure Icinga for Windows configuration file is opened as read-only for every single task besides actually modifying configuration content
2121
* [#207](https://github.com/Icinga/icinga-powershell-framework/pull/207) Adds new Argument `-LabelName` to `New-IcingaCheck`, allowing the developer to provide custom label names for checks and override the default based on the check name.
22+
* [#210](https://github.com/Icinga/icinga-powershell-framework/pull/210) Updates the Icinga DSL for building PowerShell arrays to ensure all string values are properly escaped with `'`. In case the user already wrapped commands with `'` by himself, this will not have an effect as we only add single quotes for escaping if they are not present already
2223

2324
### Bugfixes
2425

Diff for: lib/core/tools/Get-IcingaCheckCommandConfig.psm1

+3-2
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,12 @@ function Get-IcingaCheckCommandConfig()
179179
'value' = @{
180180
'type' = 'Function';
181181
'body' = [string]::Format(
182-
'var arr = macro("{0}");{1}if (len(arr) == 0) {2}{1}return "@()";{1}{3}{1}return arr.join(",");',
182+
'var arr = macro("{0}");{1} if (len(arr) == 0) {2}{1} return "@()";{1} {3}{1} return arr.map({1} x => if (typeof(x) == String) {2}{1} var argLen = len(x);{1} if (argLen != 0 && x.substr(0,1) == "{4}" && x.substr(argLen - 1, argLen) == "{4}") {2}{1} x;{1} {3} else {2}{1} "{4}" + x + "{4}";{1} {3}{1} {3} else {2}{1} x;{1} {3}{1} ).join(",");',
183183
$IcingaCustomVariable,
184184
"`r`n",
185185
'{',
186-
'}'
186+
'}',
187+
"'"
187188
);
188189
}
189190
'order' = $Order;

0 commit comments

Comments
 (0)