Skip to content

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

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/url-decode-file-paths
Draft

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

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 13, 2026

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 ($entry in $zip.Entries) {
    $decodedEntryName = [Uri]::UnescapeDataString($entry.FullName)
    $destPath = Join-Path $installPath $decodedEntryName
    # ZIP spec uses '/' but some tools emit '\'; treat both as directory entries
    if ($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.

Copilot AI and 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>
Copilot AI changed the title [WIP] Fix file paths decoding during extraction Decode URL-encoded zip entry names when extracting NuGet packages Apr 13, 2026
Copilot AI requested a review from JustinGrote April 13, 2026 03:27
Sign up for free to 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