mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-24 13:43:43 +09:00
partially backport #39400 avod writing corrupted ini config
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -180,6 +181,17 @@ func checkDatabase(ctx *context.Context, form *forms.InstallForm) bool {
|
|||||||
return true
|
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
|
// SubmitInstall response for submit install items
|
||||||
func SubmitInstall(ctx *context.Context) {
|
func SubmitInstall(ctx *context.Context) {
|
||||||
if setting.InstallLock {
|
if setting.InstallLock {
|
||||||
@@ -452,6 +464,7 @@ func SubmitInstall(ctx *context.Context) {
|
|||||||
|
|
||||||
setting.EnvironmentToConfig(cfg, os.Environ())
|
setting.EnvironmentToConfig(cfg, os.Environ())
|
||||||
|
|
||||||
|
fillInstallConfigCleanUp(cfg)
|
||||||
if err = cfg.SaveTo(setting.CustomConf); err != nil {
|
if err = cfg.SaveTo(setting.CustomConf); err != nil {
|
||||||
ctx.RenderWithErrDeprecated(ctx.Tr("install.save_config_failed", err), tplInstall, &form)
|
ctx.RenderWithErrDeprecated(ctx.Tr("install.save_config_failed", err), tplInstall, &form)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user