Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/gcompress: 包含中文文件名的zip解压乱码 #3980

Open
nuan1989 opened this issue Nov 27, 2024 · 5 comments
Open

encoding/gcompress: 包含中文文件名的zip解压乱码 #3980

nuan1989 opened this issue Nov 27, 2024 · 5 comments
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. help wanted

Comments

@nuan1989
Copy link

nuan1989 commented Nov 27, 2024

Go version

go 1.20

GoFrame version

2.8.1

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

2

测试代码:
测试代码.zip

What did you see happen?

包含中文文件名的zip解压乱码,
1

What did you expect to see?

希望解压的时候, 可以判断下文件名编码.
我在百度找了一个不会乱码的, 上传上来供你参考.
main.zip

@nuan1989 nuan1989 added the bug It is confirmed a bug, but don't worry, we'll handle it. label Nov 27, 2024
@gqcn
Copy link
Member

gqcn commented Dec 1, 2024

猜测是编码与解码的中文编码不一致造成的,尤其是zip打包使用的是utf8,但是解压的环境系统使用的是gbk编码。我不确定gcompress压缩时使用的编码是否是固定的utf8,因为使用了标准库的zip.FileInfoHeader生成文件路径。期望有小伙伴来参与贡献。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The guess is that the encoding and decoding are inconsistent with the Chinese encoding, especially the zip packaging uses utf8, but the decompression environment system uses gbk encoding. I'm not sure if the encoding used by gcompress when compressing is fixed utf8, since the standard library's zip.FileInfoHeader is used to generate the file path. Hope some friends can participate and contribute.

Copy link

github-actions bot commented Dec 1, 2024

Hello @nuan1989. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it!
你好 @nuan1989。我们喜欢您的提案/反馈,并希望您或其他社区成员通过拉取请求做出贡献。我们提前感谢您的贡献,并期待对其进行审查。

@nuan1989
Copy link
Author

nuan1989 commented Dec 1, 2024

猜测是编码与解码的中文编码不一致造成的,尤其是zip打包使用的是,但是解压的环境系统使用的是编码。我不确定压缩时使用的编码是否是固定的,因为使用了标准库的生成文件路径。期望有小伙伴来参与贡献。utf8``gbk``gcompress``utf8``zip.FileInfoHeader

haha ..我比较菜 , 做不了贡献, 直接在百度找了一个能用的将就用用. 我猜测go标准库也会这样.

这是百度找的可运行的代码
https://github.com/user-attachments/files/17933863/main.zip

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It is speculated that the encoding and decoding are inconsistent with the Chinese encoding, especially the zip packaging uses the encoding, but the decompression environment system uses the encoding. I'm not sure if the encoding used when compressing is fixed since the makefile path of the standard library is used. Hope some friends can participate and contribute. utf8``gbk``gcompress``utf8``zip.FileInfoHeader

haha... I'm a noob and can't contribute much, so I just found a working one on Baidu and just used it. I guess the same goes for the go standard library.

This is the executable code found by Baidu
https://github.com/user-attachments/files/17933863/main.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. help wanted
Projects
None yet
Development

No branches or pull requests

3 participants