Skip to content

Tab completion for Where-Object and Foreach-Object does not escape single quotes in property names #24493

@dkaszews

Description

@dkaszews

Prerequisites

Steps to reproduce

For PSCustomObject's (and likely others) properties containing characters like spaces and quotes, tab completion automatically quotes and escapes them. As example payload, take:

> $employees = "ID,Employee's name`n1,Alice`n2,Bob"

While $employees[0].E<TAB> will correctly produce $employees[0].'Employee''s name', doubling single quote to escape it, it is not done for Where-Object and ForEach-Object.

Expected behavior

> $Employees | % E<TAB>
$Employees | % 'Employee''s name'

Actual behavior

> $Employees | % E<TAB>
$Employees | % 'Employee's name'

Error details

Pressing enter waits for input due to unclosed quote.

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.5
PSEdition                      Core
GitCommitId                    7.4.5
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.WG-Interactive-IntelliSensetab completionWG-NeedsReviewNeeds a review by the labeled Working Group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions