Auto-detect and convert GBK-encoded archive filenames to UTF-8#24
Merged
Conversation
Co-authored-by: vlssu <43847794+vlssu@users.noreply.github.com>
Co-authored-by: vlssu <43847794+vlssu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix GBK detection and conversion issue
Auto-detect and convert GBK-encoded archive filenames to UTF-8
Jan 19, 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.
Windows applications in China commonly create ZIP files with GBK-encoded filenames instead of UTF-8, causing extraction to fail with garbled filenames like
open [�����]��Ȼ����v1.2: invalid argument.Changes
decodeFilename()helper: Detects encoding using UTF-8 validation—if invalid, decodes as GBK; otherwise passes through unchangedf.NameInArchivebefore path construction inextractStream()test-gbk.zipwith GBK-encoded Chinese filenames and corresponding testsImplementation
Applied at extraction:
This handles UTF-8, GBK, and ASCII filenames transparently without configuration.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
emperror.dev/update-job-proxy /update-job-proxy -trimpath= -nolocalimports ux_amd64/vet go_.�� x64/src/net 8925888/b129/ ux_amd64/vet -p weak -lang=go1.24 ux_amd64/vet 8925�� g_.a -I x64/pkg/tool/linux_amd64/vet --gdwarf-5 g/x/sys/cpu -o x64/pkg/tool/linux_amd64/vet(dns block)/update-job-proxy /update-job-proxy -o br-7e8f4456b9ff -j DROP REDACTED 18885ac2:go.mod e/git-remote-https ock fa09c952e3eadbffcat-file /bin/git e/git-remote-httc2b33e8439af944379acbdd9c3a5fe0bc44bd8a5:go.mod fetc�� om/smartystreets/go-aws-auth origin /bin/git refs/tags/*:refs/usr/sbin/iptables riter/go.mod ps /usr/bin/git(dns block)go.googlesource.com/update-job-proxy /update-job-proxy -trimpath= -nolocalimports ux_amd64/vet go_.�� x64/src/net 8925888/b129/ ux_amd64/vet -p weak -lang=go1.24 ux_amd64/vet 8925�� g_.a -I x64/pkg/tool/linux_amd64/vet --gdwarf-5 g/x/sys/cpu -o x64/pkg/tool/linux_amd64/vet(dns block)/update-job-proxy /update-job-proxy -o br-7e8f4456b9ff -j DROP REDACTED 18885ac2:go.mod e/git-remote-https ock fa09c952e3eadbffcat-file /bin/git e/git-remote-httc2b33e8439af944379acbdd9c3a5fe0bc44bd8a5:go.mod fetc�� om/smartystreets/go-aws-auth origin /bin/git refs/tags/*:refs/usr/sbin/iptables riter/go.mod ps /usr/bin/git(dns block)go.opentelemetry.io/update-job-proxy /update-job-proxy -trimpath= -nolocalimports ux_amd64/vet go_.�� x64/src/net 8925888/b129/ ux_amd64/vet -p weak -lang=go1.24 ux_amd64/vet 8925�� g_.a -I x64/pkg/tool/linux_amd64/vet --gdwarf-5 g/x/sys/cpu -o x64/pkg/tool/linux_amd64/vet(dns block)/update-job-proxy /update-job-proxy -o br-7e8f4456b9ff -j DROP REDACTED 18885ac2:go.mod e/git-remote-https ock fa09c952e3eadbffcat-file /bin/git e/git-remote-httc2b33e8439af944379acbdd9c3a5fe0bc44bd8a5:go.mod fetc�� om/smartystreets/go-aws-auth origin /bin/git refs/tags/*:refs/usr/sbin/iptables riter/go.mod ps /usr/bin/git(dns block)go.uber.org/update-job-proxy /update-job-proxy -trimpath= -nolocalimports ux_amd64/vet go_.�� x64/src/net 8925888/b129/ ux_amd64/vet -p weak -lang=go1.24 ux_amd64/vet 8925�� g_.a -I x64/pkg/tool/linux_amd64/vet --gdwarf-5 g/x/sys/cpu -o x64/pkg/tool/linux_amd64/vet(dns block)/update-job-proxy /update-job-proxy -o br-7e8f4456b9ff -j DROP REDACTED 18885ac2:go.mod e/git-remote-https ock fa09c952e3eadbffcat-file /bin/git e/git-remote-httc2b33e8439af944379acbdd9c3a5fe0bc44bd8a5:go.mod fetc�� om/smartystreets/go-aws-auth origin /bin/git refs/tags/*:refs/usr/sbin/iptables riter/go.mod ps /usr/bin/git(dns block)go4.org/update-job-proxy /update-job-proxy -trimpath= -nolocalimports ux_amd64/vet go_.�� x64/src/net 8925888/b129/ ux_amd64/vet -p weak -lang=go1.24 ux_amd64/vet 8925�� g_.a -I x64/pkg/tool/linux_amd64/vet --gdwarf-5 g/x/sys/cpu -o x64/pkg/tool/linux_amd64/vet(dns block)/update-job-proxy /update-job-proxy -o br-7e8f4456b9ff -j DROP REDACTED 18885ac2:go.mod e/git-remote-https ock fa09c952e3eadbffcat-file /bin/git e/git-remote-httc2b33e8439af944379acbdd9c3a5fe0bc44bd8a5:go.mod fetc�� om/smartystreets/go-aws-auth origin /bin/git refs/tags/*:refs/usr/sbin/iptables riter/go.mod ps /usr/bin/git(dns block)google.golang.org/update-job-proxy /update-job-proxy -trimpath= -nolocalimports ux_amd64/vet go_.�� x64/src/net 8925888/b129/ ux_amd64/vet -p weak -lang=go1.24 ux_amd64/vet 8925�� g_.a -I x64/pkg/tool/linux_amd64/vet --gdwarf-5 g/x/sys/cpu -o x64/pkg/tool/linux_amd64/vet(dns block)/update-job-proxy /update-job-proxy -o br-7e8f4456b9ff -j DROP REDACTED 18885ac2:go.mod e/git-remote-https ock fa09c952e3eadbffcat-file /bin/git e/git-remote-httc2b33e8439af944379acbdd9c3a5fe0bc44bd8a5:go.mod fetc�� om/smartystreets/go-aws-auth origin /bin/git refs/tags/*:refs/usr/sbin/iptables riter/go.mod ps /usr/bin/git(dns block)gopkg.in/update-job-proxy /update-job-proxy -trimpath= -nolocalimports ux_amd64/vet go_.�� x64/src/net 8925888/b129/ ux_amd64/vet -p weak -lang=go1.24 ux_amd64/vet 8925�� g_.a -I x64/pkg/tool/linux_amd64/vet --gdwarf-5 g/x/sys/cpu -o x64/pkg/tool/linux_amd64/vet(dns block)/update-job-proxy /update-job-proxy -o br-7e8f4456b9ff -j DROP REDACTED 18885ac2:go.mod e/git-remote-https ock fa09c952e3eadbffcat-file /bin/git e/git-remote-httc2b33e8439af944379acbdd9c3a5fe0bc44bd8a5:go.mod fetc�� om/smartystreets/go-aws-auth origin /bin/git refs/tags/*:refs/usr/sbin/iptables riter/go.mod ps /usr/bin/git(dns block)gorm.io/update-job-proxy /update-job-proxy -trimpath= -nolocalimports ux_amd64/vet go_.�� x64/src/net 8925888/b129/ ux_amd64/vet -p weak -lang=go1.24 ux_amd64/vet 8925�� g_.a -I x64/pkg/tool/linux_amd64/vet --gdwarf-5 g/x/sys/cpu -o x64/pkg/tool/linux_amd64/vet(dns block)/update-job-proxy /update-job-proxy -o br-7e8f4456b9ff -j DROP REDACTED 18885ac2:go.mod e/git-remote-https ock fa09c952e3eadbffcat-file /bin/git e/git-remote-httc2b33e8439af944379acbdd9c3a5fe0bc44bd8a5:go.mod fetc�� om/smartystreets/go-aws-auth origin /bin/git refs/tags/*:refs/usr/sbin/iptables riter/go.mod ps /usr/bin/git(dns block)gotest.tools/update-job-proxy /update-job-proxy -trimpath= -nolocalimports ux_amd64/vet go_.�� x64/src/net 8925888/b129/ ux_amd64/vet -p weak -lang=go1.24 ux_amd64/vet 8925�� g_.a -I x64/pkg/tool/linux_amd64/vet --gdwarf-5 g/x/sys/cpu -o x64/pkg/tool/linux_amd64/vet(dns block)/update-job-proxy /update-job-proxy -o br-7e8f4456b9ff -j DROP REDACTED 18885ac2:go.mod e/git-remote-https ock fa09c952e3eadbffcat-file /bin/git e/git-remote-httc2b33e8439af944379acbdd9c3a5fe0bc44bd8a5:go.mod fetc�� om/smartystreets/go-aws-auth origin /bin/git refs/tags/*:refs/usr/sbin/iptables riter/go.mod ps /usr/bin/git(dns block)modernc.org/update-job-proxy /update-job-proxy -trimpath= -nolocalimports ux_amd64/vet go_.�� x64/src/net 8925888/b129/ ux_amd64/vet -p weak -lang=go1.24 ux_amd64/vet 8925�� g_.a -I x64/pkg/tool/linux_amd64/vet --gdwarf-5 g/x/sys/cpu -o x64/pkg/tool/linux_amd64/vet(dns block)/update-job-proxy /update-job-proxy -o br-7e8f4456b9ff -j DROP REDACTED 18885ac2:go.mod e/git-remote-https ock fa09c952e3eadbffcat-file /bin/git e/git-remote-httc2b33e8439af944379acbdd9c3a5fe0bc44bd8a5:go.mod fetc�� om/smartystreets/go-aws-auth origin /bin/git refs/tags/*:refs/usr/sbin/iptables riter/go.mod ps /usr/bin/git(dns block)nullprogram.com/update-job-proxy /update-job-proxy -trimpath= -nolocalimports ux_amd64/vet go_.�� x64/src/net 8925888/b129/ ux_amd64/vet -p weak -lang=go1.24 ux_amd64/vet 8925�� g_.a -I x64/pkg/tool/linux_amd64/vet --gdwarf-5 g/x/sys/cpu -o x64/pkg/tool/linux_amd64/vet(dns block)/update-job-proxy /update-job-proxy -o br-7e8f4456b9ff -j DROP REDACTED 18885ac2:go.mod e/git-remote-https ock fa09c952e3eadbffcat-file /bin/git e/git-remote-httc2b33e8439af944379acbdd9c3a5fe0bc44bd8a5:go.mod fetc�� om/smartystreets/go-aws-auth origin /bin/git refs/tags/*:refs/usr/sbin/iptables riter/go.mod ps /usr/bin/git(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This section details on the original issue you should resolve
<issue_title>[求助]检测是否为GBK,并判断是否要转换</issue_title>
<issue_description>https://github.com/pterodactyl-china/wings/blob/gbkconvert/server/filesystem/compress.go
wings/server/filesystem/compress.go
Lines 233 to 238 in 48eaf03
判断为true时会将 GBK 转换为 UTF-8,false则直接输出不进行转换。
编译没问题
wings/server/filesystem/compress.go
Line 237 in 48eaf03
在237行我想直接输出 179行的
strwings/server/filesystem/compress.go
Line 179 in 48eaf03
但在测试中,true时转换成功并解压文件,false时直接无响应(卡进程)。
对应的wings测试版本
https://github.com/vlssu/wings/actions/runs/3195622098
如果有更好的思路,可以在源代码的基础上重新编写修复。 https://github.com/pterodactyl-china/wings/blob/develop/server/filesystem/compress.go</issue_description>
<agent_instructions>解压文件可以自动识别是不是GBK还是UTF-8,来正确的解压操作</agent_instructions>
Comments on the Issue (you are @copilot in this section)
@vlssu GBK的压缩包可以用于测试 [测试压缩包.zip](https://github.com/pterodactyl/panel/files/9075730/default.zip) ``` 测试压缩包.zip │ 测试文档.md │ └─测试文件夹 测试核心-arclight-forge-1.18.2-1.0.5.jar ``` UTF-8 的压缩包,可以使用面板上的压缩,再解压来进行测试 @vlssu > 呃 测试用的 UTF8 压缩包结果也被转成 GBK 了,你有什么头绪吗  GBK 压缩包测试结果倒是正常的.用的是这个吗?https://github.com/vlssu/wings/actions/runs/3195622098</comment_new>
<comment_new>@vlssu
在新版中,检测到的文件名是乱码的,并且无法正常工作