Fix short 8.3 paths in file system normalization by huong8373tt-beep · Pull Request #28172 · PowerShell/PowerShell · GitHub
Skip to content

Fix short 8.3 paths in file system normalization - #28172

Open
Slai.life (huong8373tt-beep) wants to merge 2 commits into
PowerShell:masterfrom
huong8373tt-beep:slai/fix-short-83-path-normalization
Open

Slai.life (huong8373tt-beep) wants to merge 2 commits into
PowerShell:masterfrom
huong8373tt-beep:slai/fix-short-83-path-normalization

Conversation

@huong8373tt-beep

@huong8373tt-beep Slai.life (huong8373tt-beep) commented Oct 8, 2026 •

Copy link
Copy Markdown

Summary

  • distinguish an over-normalized path component from an 8.3 alias that resolves to the same item with a shorter long name
  • preserve the existing rejection for components that .NET resolves to their parent directory
  • add Windows regression coverage for Remove-Item through an A~1 alias whose long name is a

Fixes #21070.

Testing

  • Start-PSBuild -Runtime win7-x64 -Configuration Debug -NoPSModuleRestore -SkipExperimentalFeatureGeneration
  • targeted FileSystem.Tests.ps1 Pester test: 1 passed, 0 failed
  • reproduced the failure with released PowerShell 7.6.6, then verified the built pwsh removes the same short-path target successfully

AI-assisted disclosure

This contribution was prepared after reproducing issue #21070 in a Windows environment. The developer authorized this contribution after the issue was reproduced and the fix was validated. Slai Agent Runtime assisted with reproduction, implementation, and test execution; the account owner is responsible for this submission.

@huong8373tt-beep
Slai.life (huong8373tt-beep) requested a review from a team as a code owner October 8, 2026 20:13
Copilot AI balanced review requested due to automatic review settings October 8, 2026 20:13
@azure-pipelines

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The regression test can mask failures as skips and does not cover the preserved parent-resolution behavior.

3 open findings
What changed in this PR

Fixes Windows filesystem normalization when an 8.3 alias expands to a shorter long name while retaining parent-directory normalization protection.

Changes:

  • Compares normalized paths against their parent before rejecting shortened paths.
  • Adds Windows regression coverage for removal through an 8.3 alias.
File Description
FileSystem.Tests.ps1 Adds short-path removal coverage.
FileSystemProvider.cs Refines path over-normalization detection.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +5709 to +5713
var parentInfo = GetFileSystemInfo(GetParentPath(currentPath, null), out bool _);
if (string.Equals(
fsinfo.FullName.TrimEnd(StringLiterals.DefaultPathSeparator),
parentInfo?.FullName.TrimEnd(StringLiterals.DefaultPathSeparator),
StringComparison.OrdinalIgnoreCase))
try {
$null = New-Item -ItemType Directory -Path $longDirectory -Force
& fsutil file setshortname $longDirectory 'A~1' 2>$null | Out-Null
if ($LASTEXITCODE -ne 0 -or -not (Test-Path -LiteralPath $shortDirectory)) {

try {
$null = New-Item -ItemType Directory -Path $longDirectory -Force
& fsutil file setshortname $longDirectory 'A~1' 2>$null | Out-Null
Signed-off-by: wangluoye <294879785+huong8373tt-beep@users.noreply.github.com>
@huong8373tt-beep

Copy link
Copy Markdown
Author

Addressed the three Copilot findings in 99f124b:

  • added regression coverage for the preserved parent-resolution rejection;
  • verify 8.3 alias availability with System.IO rather than the provider under test;
  • use Start-NativeExecution -IgnoreExitcode for fsutil.

Validated with the Windows Debug build and both the short-alias and parent-resolution regression cases. The review comments target the prior commit.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Review - Needed The PR is being reviewed label Oct 16, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review - Needed The PR is being reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PowerShell doesn't delete file in $env:TEMP if account contains a cyrillic char

2 participants