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

[求助]检测是否为GBK,并判断是否要转换 #4

Open
vlssu opened this issue Oct 6, 2022 · 3 comments
Open

[求助]检测是否为GBK,并判断是否要转换 #4

vlssu opened this issue Oct 6, 2022 · 3 comments

Comments

@vlssu
Copy link
Member

vlssu commented Oct 6, 2022

https://github.com/pterodactyl-china/wings/blob/gbkconvert/server/filesystem/compress.go

if ifgbk == true {
utf8Str, _ := simplifiedchinese.GBK.NewDecoder().Bytes([]byte(str))
return string(utf8Str)
} else {
return string(str)
}

判断为true时会将 GBK 转换为 UTF-8,false则直接输出不进行转换。
编译没问题


return string(str)

在237行我想直接输出 179行的str
str := f.Name()

但在测试中,true时转换成功并解压文件,false时直接无响应(卡进程)。

对应的wings测试版本
https://github.com/vlssu/wings/actions/runs/3195622098

如果有更好的思路,可以在源代码的基础上重新编写修复。 https://github.com/pterodactyl-china/wings/blob/develop/server/filesystem/compress.go

@vlssu
Copy link
Member Author

vlssu commented Oct 6, 2022

GBK的压缩包可以用于测试
测试压缩包.zip

  测试压缩包.zip
    │  测试文档.md
    │
    └─测试文件夹
            测试核心-arclight-forge-1.18.2-1.0.5.jar

UTF-8 的压缩包,可以使用面板上的压缩,再解压来进行测试

@vlssu
Copy link
Member Author

vlssu commented Oct 7, 2022 via email

@vlssu vlssu closed this as completed Oct 10, 2022
@vlssu vlssu reopened this Oct 10, 2023
@vlssu
Copy link
Member Author

vlssu commented Oct 10, 2023

在新版中,检测到的文件名是乱码的,并且无法正常工作

ERROR: [Sep  4 17:47:57.524] error while handling HTTP request error=open [�����]��Ȼ����v1.2: invalid argument request_id=16b754ca-9839-4838-8fd6-d0726757b6b4 server_id=e2531742-2c9f-4a52-a1db-95baaa81256f status=500 url=/api/servers/e2531742-2c9f-4a52-a1db-95baaa81256f/files/decompress

Stacktrace:
open [�����]��Ȼ����v1.2: invalid argument
github.com/pterodactyl/wings/router.postServerDecompressFiles
        github.com/pterodactyl/wings/router/router_server_files.go:450
github.com/gin-gonic/gin.(*Context).Next
        github.com/gin-gonic/[email protected]/context.go:174
github.com/pterodactyl/wings/router/middleware.ServerExists.func1
        github.com/pterodactyl/wings/router/middleware/middleware.go:158
github.com/gin-gonic/gin.(*Context).Next
        github.com/gin-gonic/[email protected]/context.go:174
github.com/pterodactyl/wings/router/middleware.RequireAuthorization.func1
        github.com/pterodactyl/wings/router/middleware/middleware.go:186
github.com/gin-gonic/gin.(*Context).Next
        github.com/gin-gonic/[email protected]/context.go:174
github.com/pterodactyl/wings/router/middleware.RequireAuthorization.func1
        github.com/pterodactyl/wings/router/middleware/middleware.go:186
github.com/gin-gonic/gin.(*Context).Next
        github.com/gin-gonic/[email protected]/context.go:174
github.com/gin-gonic/gin.LoggerWithConfig.func1
        github.com/gin-gonic/[email protected]/logger.go:240
github.com/gin-gonic/gin.(*Context).Next
        github.com/gin-gonic/[email protected]/context.go:174
github.com/pterodactyl/wings/router/middleware.AttachApiClient.func1
        github.com/pterodactyl/wings/router/middleware/middleware.go:51
github.com/gin-gonic/gin.(*Context).Next
        github.com/gin-gonic/[email protected]/context.go:174
github.com/pterodactyl/wings/router/middleware.AttachServerManager.func1
        github.com/pterodactyl/wings/router/middleware/middleware.go:42
github.com/gin-gonic/gin.(*Context).Next
        github.com/gin-gonic/[email protected]/context.go:174
github.com/pterodactyl/wings/router/middleware.SetAccessControlHeaders.func1
        github.com/pterodactyl/wings/router/middleware/middleware.go:135
github.com/gin-gonic/gin.(*Context).Next
        github.com/gin-gonic/[email protected]/context.go:174
github.com/pterodactyl/wings/router/middleware.CaptureErrors.func1
        github.com/pterodactyl/wings/router/middleware/middleware.go:68
github.com/gin-gonic/gin.(*Context).Next
        github.com/gin-gonic/[email protected]/context.go:174
github.com/pterodactyl/wings/router/middleware.AttachRequestID.func1
        github.com/pterodactyl/wings/router/middleware/middleware.go:33
github.com/gin-gonic/gin.(*Context).Next
        github.com/gin-gonic/[email protected]/context.go:174
github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1
        github.com/gin-gonic/[email protected]/recovery.go:102
github.com/gin-gonic/gin.(*Context).Next
        github.com/gin-gonic/[email protected]/context.go:174
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
        github.com/gin-gonic/[email protected]/gin.go:620
github.com/gin-gonic/gin.(*Engine).ServeHTTP
        github.com/gin-gonic/[email protected]/gin.go:576
net/http.serverHandler.ServeHTTP
        net/http/server.go:2947
net/http.(*conn).serve
        net/http/server.go:1991
runtime.goexit
        runtime/asm_amd64.s:1594

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

No branches or pull requests

1 participant