fix: "install" page (#39400) (#39401)

partially backport #39400

avod writing corrupted ini config
This commit is contained in:
wxiaoguang
2026-09-23 15:06:50 +00:00
committed by GitHub
parent 0dc8bf8848
commit 3298b8b62c
+13
View File
@@ -10,6 +10,7 @@ import (
"os"
"os/exec"
"path/filepath"
"regexp"
"slices"
"strconv"
"strings"
@@ -180,6 +181,17 @@ func checkDatabase(ctx *context.Context, form *forms.InstallForm) bool {
return true
}
func fillInstallConfigCleanUp(cfg setting.ConfigProvider) {
re := regexp.MustCompile(`[\x00-\x1F\x7F]`)
for _, sec := range cfg.Sections() {
for _, key := range sec.Keys() {
s := key.String()
s = re.ReplaceAllString(s, " ")
key.SetValue(s)
}
}
}
// SubmitInstall response for submit install items
func SubmitInstall(ctx *context.Context) {
if setting.InstallLock {
@@ -452,6 +464,7 @@ func SubmitInstall(ctx *context.Context) {
setting.EnvironmentToConfig(cfg, os.Environ())
fillInstallConfigCleanUp(cfg)
if err = cfg.SaveTo(setting.CustomConf); err != nil {
ctx.RenderWithErrDeprecated(ctx.Tr("install.save_config_failed", err), tplInstall, &form)
return