Skip to content

Decode URL-encoded zip entry names when extracting NuGet packages - #116

Draft
JustinGrote with Copilot wants to merge 3 commits into
mainfrom
copilot/url-decode-file-paths
Draft

Decode URL-encoded zip entry names when extracting NuGet packages#116
JustinGrote with Copilot wants to merge 3 commits into
mainfrom
copilot/url-decode-file-paths

Conversation

CopilotAI commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

NuGet packages percent-encode file paths in their zip entries (e.g. spaces → %20). ZipFileExtensions.ExtractToDirectory does not decode these, resulting in files being written with names like file%20with%20spaces.txt on disk instead of file with spaces.txt.

Changes

  • ModuleFast.psm1: Replace the single ExtractToDirectory call with a manual loop that applies [Uri]::UnescapeDataString to each entry's FullName before constructing the destination path, then extracts via ZipFileExtensions.ExtractToFile. Directory entries (both / and \ terminators) are handled explicitly.
foreach ($entryin$zip.Entries) {
$decodedEntryName= [Uri]::UnescapeDataString($entry.FullName)
$destPath=Join-Path$installPath$decodedEntryName# ZIP spec uses '/' but some tools emit '\'; treat both as directory entriesif ($decodedEntryName.EndsWith('/') -or$decodedEntryName.EndsWith('\')) {
New-Item-ItemType Directory -Path $destPath-Force |Out-Null
} else {
$destDir= [Path]::GetDirectoryName($destPath)
if (-not (Test-Path$destDir)) { New-Item-ItemType Directory -Path $destDir-Force |Out-Null }
[IO.Compression.ZipFileExtensions]::ExtractToFile($entry,$destPath,$true)
}
}
  • ModuleFast.tests.ps1: Unit test added that builds an in-memory ZIP with percent-encoded directory and file entries, runs the extraction logic, and asserts decoded paths exist while encoded paths do not.

CopilotAIand others added 2 commits April 13, 2026 03:25
…st to cover directory entries
Agent-Logs-Url: https://github.com/JustinGrote/ModuleFast/sessions/d72bd0f4-f6fb-4703-ad8d-33d3fb81f9cb
Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
CopilotAI changed the title [WIP] Fix file paths decoding during extractionDecode URL-encoded zip entry names when extracting NuGet packagesApr 13, 2026
CopilotAI requested a review from JustinGroteApril 13, 2026 03:27
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File paths need to be Url decoded when extracting

2 participants

@JustinGrote