diff --git a/backend/app/service/file.go b/backend/app/service/file.go index e9c67a2e1..177b7e839 100644 --- a/backend/app/service/file.go +++ b/backend/app/service/file.go @@ -10,6 +10,7 @@ import ( "path/filepath" "strings" "time" + "unicode/utf8" "github.com/1Panel-dev/1Panel/backend/app/dto/request" "github.com/1Panel-dev/1Panel/backend/app/dto/response" @@ -236,20 +237,20 @@ func (f *FileService) GetContent(op request.FileContentReq) (response.FileInfo, } content := []byte(info.Content) - var decodeName string if len(content) > 1024 { - _, decodeName, _ = charset.DetermineEncoding(content[:1024], "") - } else { - _, decodeName, _ = charset.DetermineEncoding(content, "") + content = content[:1024] } - if decodeName == "windows-1252" { - reader := strings.NewReader(info.Content) - item := transform.NewReader(reader, simplifiedchinese.GBK.NewDecoder()) - contents, err := io.ReadAll(item) - if err != nil { - return response.FileInfo{}, err + if !utf8.Valid(content) { + _, decodeName, _ := charset.DetermineEncoding(content, "") + if decodeName == "windows-1252" { + reader := strings.NewReader(info.Content) + item := transform.NewReader(reader, simplifiedchinese.GBK.NewDecoder()) + contents, err := io.ReadAll(item) + if err != nil { + return response.FileInfo{}, err + } + info.Content = string(contents) } - info.Content = string(contents) } return response.FileInfo{FileInfo: *info}, nil } diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index eaec0d784..6565e8c87 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1729,7 +1729,8 @@ const message = { takeDown: 'TakeDown', allReadyInstalled: 'Installed', installHelper: 'Configuring image acceleration can solve the problem of image pull failure', - upgradeHelper: 'The abnormal application needs to be synchronized to the normal state first', + upgradeHelper: + 'Abnormal applications need to be synchronized to normal status first. If the upgrade fails, please check the failure reason in the log audit-system log', installWarn: 'Currently, if the port external access is not checked, it will not be able to access through the external network IP: port. Do you want to continue?', showIgnore: 'View ignore application', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 616d0693c..992dc3797 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -1610,7 +1610,7 @@ const message = { takeDown: '已廢棄', allReadyInstalled: '已安裝', installHelper: '配置鏡像加速可以解決鏡像拉取失敗的問題', - upgradeHelper: '異常應用需要先同步到正常狀態', + upgradeHelper: '異常應用程式需要先同步到正常狀態,升級失敗請在日誌審計-系統日誌中查看失敗原因', installWarn: '當前未勾選端口外部訪問,將無法通過外網IP:端口訪問,是否繼續? ', showIgnore: '查看忽略應用', cancelIgnore: '取消忽略', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 3106b4b95..3c159479f 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1610,7 +1610,7 @@ const message = { takeDown: '已废弃', allReadyInstalled: '已安装', installHelper: '配置镜像加速可以解决镜像拉取失败的问题', - upgradeHelper: '异常应用需要先同步到正常状态', + upgradeHelper: '异常应用需要先同步到正常状态,升级失败请在日志审计-系统日志中查看失败原因', installWarn: '当前未勾选端口外部访问,将无法通过外网IP:端口访问,是否继续?', showIgnore: '查看忽略应用', cancelIgnore: '取消忽略',