Skip to content

ConvertFrom-StringData: datafield after the first delimiter should be literal string. #20417

@237dmitry

Description

@237dmitry

Prerequisites

Steps to reproduce

\C characters sequence in the field after the separator causes an error:

$ 'aaa=aaa\Ccc' | ConvertFrom-StringData                                                 
ConvertFrom-StringData: Invalid pattern 'aaa\Ccc' at offset 5. Unrecognized escape sequence \C.

Expected behavior

Data field after the first delimiter should be the literal. Without escapes:


$ 'aaa=aaa\\Ccc' | ConvertFrom-StringData

Name                           Value
----                           -----
aaa                            aaa\Ccc

Actual behavior

Data field causes the parse error

Error details

$ (Get-Error).Exception                                                                        

Type           : System.Text.RegularExpressions.RegexParseException
Error          : UnrecognizedEscape
Offset         : 5
Message        : Invalid pattern 'aaa\Ccc' at offset 5. Unrecognized escape sequence \C.
ParamName      : 
TargetSite     : Char ScanCharEscape()
Data           : {}
InnerException : 
HelpLink       : 
Source         : System.Text.RegularExpressions
HResult        : -2147024809
StackTrace     :    at System.Text.RegularExpressions.RegexParser.ScanCharEscape()
                    at System.Text.RegularExpressions.RegexParser.UnescapeImpl(String input, Int32 i)
                    at Microsoft.PowerShell.Commands.ConvertFromStringDataCommand.ProcessRecord()
                    at System.Management.Automation.CommandProcessor.ProcessRecord()

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.0-preview.6
PSEdition                      Core
GitCommitId                    7.4.0-preview.6
OS                             ArcoLinux
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

ss

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions