Skip to content

Convert-Path to to a standard registry path fail if a forward backslash is present #24586

@GaetanRabier

Description

@GaetanRabier

Prerequisites

Steps to reproduce

Easily reproducible :
Convert-Path -Path "HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\I/O System"

Expected behavior

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\I/O System

Actual behavior

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\I\O System

Error details

The forward back slash at the end (between I and O) is converted to a regular backslash.
This is due to the call to MakePath that is converting all the slashs from the child path.

https://github.com/cobbr/InsecurePowerShell/blob/fed7a542da3346c0f686157990e0c8a954b108c8/src/System.Management.Automation/namespaces/NavigationProviderBase.cs#L386

We should instead divide the path into multiple variables and then reassemble them.

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.6
PSEdition                      Core
GitCommitId                    7.4.6
OS                             Microsoft Windows 10.0.26100
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

    In-PRIndicates that a PR is out for the issueResolution-DuplicateThe issue is a duplicate.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions