-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue with escaped double quotes in CIM array #39
Fix issue with escaped double quotes in CIM array #39
Conversation
@NikCharlebois Ready for review. Got confirmation over in microsoft/Microsoft365DSC#5396 that it now works. |
@NikCharlebois Can you please take a look at this PR? |
I have fixed a different issue yesterday, which is now in ReverseDSC but which looks very similar. Could you please check the issue with the most recent version of ReverseDSC? FYI: I am working on another issue that was discovered yesterday. Will create a PR for that later, so any required additional changes I can include with this PR. |
@ykuijs Unfortunately it's not fixed with your change. I just checked with the Settings = @(
MSFT_MicrosoftGraphappConfigurationSettingItem{
AppConfigKey = "URLBlocklist"
AppConfigKeyType = "stringType"
AppConfigKeyValue = "[`"edge://flags`", `"edge://inspect`", `"edge://optimization-guide-internals`"]"
}
MSFT_MicrosoftGraphappConfigurationSettingItem{
AppConfigKey = "ManagedFavorites"
AppConfigKeyType = "stringType"
AppConfigKeyValue = "[{ `"toplevel_name`": `"My managed favorites folder`" }, { `"name`": `"Google`", `"url`": `"google.com`" }, { `"name`": `"Yahoo`", `"url`": `"yahoo.com`" }]"
}
); but instead, it is: Settings = @(
MSFT_MicrosoftGraphappConfigurationSettingItem{
AppConfigKey = "URLBlocklist"
AppConfigKeyType = "stringType"
AppConfigKeyValue = "["edge://flags`, `edge://inspect`, `edge://optimization-guide-internals`]`
}
MSFT_MicrosoftGraphappConfigurationSettingItem{
AppConfigKey = "ManagedFavorites"
AppConfigKeyType = "stringType"
AppConfigKeyValue = "[{ "toplevel_name`: `My managed favorites folder` }, { `name`: `Google`, `url`: `google.com` }, { `name`: `Yahoo`, `url`: `yahoo.com` }]`
}
); In the incorrect export, backticks are set and the double quotes are removed, even at the end of the property (see |
We probably did. I just added a description of what my changes tried to accomplish here: #41 (comment) |
@ykuijs I've not being paying attention to these PRs since I'm currently testing AAD resources, but please remember that like I already explained before I rely on the way that the blueprints are exported, if you change something that was single quotes before and now it's double quotes or some similar change it will affect my product. |
@ricmestre Oh yes, that is right. I totally forgot. My apologies for that! |
161aa24
to
934f438
Compare
@ykuijs I updated the PR to include your changes and re-engineered the way it works. With this version, it now correctly escapes double quotes inside of a string property in a CIM instance. Example previously: Settings = @(
MSFT_MicrosoftGraphappConfigurationSettingItem{
AppConfigKey = "URLBlocklist"
AppConfigKeyType = "stringType"
AppConfigKeyValue = "["edge://flags`, `edge://inspect`, `edge://optimization-guide-internals`]`
}
MSFT_MicrosoftGraphappConfigurationSettingItem{
AppConfigKey = "ManagedFavorites"
AppConfigKeyType = "stringType"
AppConfigKeyValue = "[{ "toplevel_name`: `My managed favorites folder` }, { `name`: `Google`, `url`: `google.com` }, { `name`: `Yahoo`, `url`: `yahoo.com` }]`
}
); And now: Settings = @(
MSFT_MicrosoftGraphappConfigurationSettingItem{
AppConfigKeyType = "stringType"
AppConfigKey = "URLBlocklist"
AppConfigKeyValue = "[`"edge://flags`", `"edge://inspect`", `"edge://optimization-guide-internals`"]"
}
MSFT_MicrosoftGraphappConfigurationSettingItem{
AppConfigKeyType = "stringType"
AppConfigKey = "ManagedFavorites"
AppConfigKeyValue = "[{ `"toplevel_name`": `"My managed favorites folder`" }, { `"name`": `"Google`", `"url`": `"google.com`" }, { `"name`": `"Yahoo`", `"url`": `"yahoo.com`" }]"
}
); The second version compiles perfectly fine and has the correct visual representation. |
This PR aims to address microsoft/Microsoft365DSC#5396 with nested quotes inside of a CIM array. Let's take the following input:
The issue here is that inside of the
settings
array with the CIM instance, there is another property namedappConfigKeyValue
. This is a string property that contains a sequence of characters and escaped double quotes. Those quotes were escaped from theGet-DSCBlock
function, unnecessarily though. That aside, when converting that input usingConvert-DSCStringParamToVariable
to the final DSC string, it removes all double quotes. But here, we don't want that to happen, since they are an integral part of theappConfigKeyValue
property.The PR handles this issue by skipping escaped double quotes inside of the CIM array element and at the end, replacing the escaped version with one that does not have the escape character in it, so that the final output is equal to what was the input to
Get-DSCBlock
.