mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix Get-ChildItem -Path with wildcard char (#9257)
Unescape non-literal, non-glob path before existence checking.
This commit is contained in:
@@ -1478,7 +1478,7 @@ namespace System.Management.Automation
|
||||
string originalPath = path;
|
||||
path =
|
||||
Globber.GetProviderPath(
|
||||
path,
|
||||
context.SuppressWildcardExpansion ? path : WildcardPattern.Unescape(path),
|
||||
context,
|
||||
out provider,
|
||||
out drive);
|
||||
@@ -2441,7 +2441,7 @@ namespace System.Management.Automation
|
||||
|
||||
string providerPath =
|
||||
Globber.GetProviderPath(
|
||||
path,
|
||||
context.SuppressWildcardExpansion ? path : WildcardPattern.Unescape(path),
|
||||
context,
|
||||
out provider,
|
||||
out drive);
|
||||
|
||||
@@ -196,6 +196,22 @@ Describe "Get-ChildItem" -Tags "CI" {
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Get-ChildItem with special path" -Tags "CI" {
|
||||
|
||||
BeforeAll {
|
||||
$bracketDirName = "Test[Dir]"
|
||||
$bracketDir = "Test``[Dir``]"
|
||||
$bracketPath = Join-Path $TestDrive $bracketDir
|
||||
$null = New-Item -Path $TestDrive -Name $bracketDirName -ItemType Directory -Force
|
||||
}
|
||||
|
||||
It "Should list files in directory with name containing bracket char" {
|
||||
$null = New-Item -Path $bracketPath -Name file1.txt -ItemType File
|
||||
$null = New-Item -Path $bracketPath -Name file2.txt -ItemType File
|
||||
Get-ChildItem -Path $bracketPath | Should -HaveCount 2
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'FileSystem Provider Formatting' -Tag "CI","RequireAdminOnWindows" {
|
||||
|
||||
BeforeAll {
|
||||
|
||||
Reference in New Issue
Block a user