Fix GBK filename decoding and file handle leaks in archive decompression#27
Merged
Fix GBK filename decoding and file handle leaks in archive decompression#27
Conversation
- Create ZipFS wrapper in archiverext package to handle GBK-encoded filenames - Automatically decode GBK to UTF-8 when walking ZIP archives - Update archiverFileSystem to use ZipFS wrapper for ZIP files - Add test for SpaceAvailableForDecompression with GBK filenames Co-authored-by: vlssu <43847794+vlssu@users.noreply.github.com>
- Add Close() method to ZipFS to properly close underlying file - Update SpaceAvailableForDecompression to close filesystem after use - Prevents file handle leaks that could cause "unexpected EOF" errors Co-authored-by: vlssu <43847794+vlssu@users.noreply.github.com>
Co-authored-by: vlssu <43847794+vlssu@users.noreply.github.com>
- Fix directory detection logic to properly handle trailing slashes
- Replace deprecated interface{} with any
- Improve directory classification using FileInfo().IsDir()
Co-authored-by: vlssu <43847794+vlssu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix invalid argument error for HTTP request handling
Fix GBK filename decoding and file handle leaks in archive decompression
Feb 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Decompressing ZIP archives with GBK-encoded filenames (common in Chinese Windows systems) fails with
invalid argumenterrors. Large file extraction occasionally fails withunexpected EOFdue to file handle conflicts.Changes
New
ZipFSwrapper (server/filesystem/archiverext/zip.go): Implementsfs.FSwith automatic GBK→UTF-8 filename transcoding. Detects non-UTF-8 filenames and decodes them as GBK transparently during filesystem operations.File handle cleanup: Added
io.Closerimplementation toZipFSand properdefer close()inSpaceAvailableForDecompression()to prevent handle leaks between space check and extraction phases.Test coverage: Added test case validating
SpaceAvailableForDecompression()with GBK-encoded filenames.Implementation
The
ZipFSwrapper intercepts all filename operations and applies this heuristic:This handles the vast majority of Chinese ZIP archives while remaining transparent to UTF-8 archives.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.