From 3298b8b62c3ab93c5aa377bcb985543cddc8d686 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 23 Sep 2026 23:06:50 +0800 Subject: [PATCH] fix: "install" page (#39400) (#39401) partially backport #39400 avod writing corrupted ini config --- routers/install/install.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/routers/install/install.go b/routers/install/install.go index 074708d5f1f..751749e6f3d 100644 --- a/routers/install/install.go +++ b/routers/install/install.go @@ -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