Skip to content

bug: get-item registry slash-magic trim'ing incorrectly #15342

@vanillaSprinkles

Description

@vanillaSprinkles

Steps to reproduce

pre-setup:

  • registry keys:
    • HKEY_CURRENT_USER\test\noslashes
    • HKEY_CURRENT_USER\test\some/test/key/
    • HKEY_CURRENT_USER\test\another//caveat/
  • or as a file.reg:
    • Windows Registry Editor Version 5.00
      [HKEY_CURRENT_USER\test]
      [HKEY_CURRENT_USER\test\another//caveat/]
      [HKEY_CURRENT_USER\test\noslashes]
      [HKEY_CURRENT_USER\test\some/test/key/]
      
## should work (and works)
get-item HKCU:\test\noslashes


## should error (and it 'works' by triming slashes)
get-item HKCU:\test\noslashes//////


## should error (and it errors)
get-item HKCU:\test\some/test/key


## should work (and it shows broken behavior)
get-item HKCU:\test\some/test/key/


## should error (and it 'works' by triming slashes)
get-item HKCU:\test\some/test/key////


## should work (and it errors)
get-item HKCU:\test\another//caveat/

Expected behavior

PS HKCU:\> ## should work (and works)
PS HKCU:\> get-item HKCU:\test\noslashes

    Hive: HKEY_CURRENT_USER\test

Name                           Property
----                           --------
noslashes




PS HKCU:\> ## should error (and it 'works' by triming slashes)
PS HKCU:\> get-item HKCU:\test\noslashes//////
Get-Item: Cannot find path 'HKCU:\test\noslashes//////' because it does not exist.




PS HKCU:\> ## should error (and it errors)
PS HKCU:\> get-item HKCU:\test\some/test/key
Get-Item: Cannot find path 'HKCU:\test\some\test\key' because it does not exist.



PS HKCU:\> ## should work (and it shows broken behavior)
PS HKCU:\> get-item HKCU:\test\some/test/key/

    Hive: HKEY_CURRENT_USER\test

Name                           Property
----                           --------
some/test/key/




PS HKCU:\> ## should error (and it 'works' by triming slashes)
PS HKCU:\> get-item HKCU:\test\some/test/key////
Get-Item: Cannot find path 'HKCU:\test\some/test/key////' because it does not exist.




PS HKCU:\> ## should work (and it errors)
PS HKCU:\> get-item HKCU:\test\another//caveat/

    Hive: HKEY_CURRENT_USER\test

Name                           Property
----                           --------
another//caveat/

Actual behavior (ps 7.1.3)

PS HKCU:\> ## should work (and works)
PS HKCU:\> get-item HKCU:\test\noslashes

    Hive: HKEY_CURRENT_USER\test

Name                           Property
----                           --------
noslashes




PS HKCU:\> ## should error (and it 'works' by triming slashes)
PS HKCU:\> get-item HKCU:\test\noslashes//////

    Hive: HKEY_CURRENT_USER\test

Name                           Property
----                           --------
noslashes




PS HKCU:\> ## should error (and it errors)
PS HKCU:\> get-item HKCU:\test\some/test/key
Get-Item: Cannot find path 'HKCU:\test\some\test\key' because it does not exist.



PS HKCU:\> ## should work (and it shows broken behavior)
PS HKCU:\> get-item HKCU:\test\some/test/key/

    Hive: HKEY_CURRENT_USER\test

Name                           Property
----                           --------
key




PS HKCU:\> ## should error (and it 'works' by triming slashes)
PS HKCU:\> get-item HKCU:\test\some/test/key////

    Hive: HKEY_CURRENT_USER\test

Name                           Property
----                           --------
key




PS HKCU:\> ## should work (and it errors)
PS HKCU:\> get-item HKCU:\test\another//caveat/
Get-Item: Cannot find path 'HKCU:\test\another\caveat\' because it does not exist.

Environment data (ps 7.1.3)

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

potentially related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-DuplicateThe issue is a duplicate.WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions