Closed jborean93 closed 1 hour ago
When emitting a quoted value the code currently escapes the ASCII single quotes correctly but it does not do it for the Unicode alternatives that are used as a single quote equivalent:
$psd1 = @{foo = "Hello $([char]0x2018)World$([char]0x2018)" } | ConvertTo-Psd1 $psd1 # @{ # foo = 'Hello ‘World‘' # } $psd1 | Invoke-Expression # Invoke-Expression: Unexpected token 'World‘'' in expression or statement.
CodeGeneration.EscapeSingleQuotedStringContent can be used to correctly escape all the quotes needed to place a value inside a single quoted string
$value = "Hello $([char]0x2018)World$([char]0x2018)" @" @{ foo = '$([System.Management.Automation.Language.CodeGeneration]::EscapeSingleQuotedStringContent($value))' } "@ # @{ # foo = 'Hello ‘‘World‘‘' # }
Thanks for the catch and proposing a solution. Fix implemented and released in v1.0.1
Thanks for the speedy fix.
When emitting a quoted value the code currently escapes the ASCII single quotes correctly but it does not do it for the Unicode alternatives that are used as a single quote equivalent:
CodeGeneration.EscapeSingleQuotedStringContent can be used to correctly escape all the quotes needed to place a value inside a single quoted string