From 6779c351b1c369141c777af01ac3c3e388426500 Mon Sep 17 00:00:00 2001 From: zeripath Date: Tue, 23 Aug 2022 15:14:02 +0100 Subject: [PATCH] Fix mirror address setting not working (#20850) (#20904) Backport #20850 This patch fixes the issue that the mirror address field is ignored from the repo setting form. Co-authored-by: Gary Wang Co-authored-by: Lunny Xiao --- routers/web/repo/setting.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go index 57e44630f68..fdac191ae6f 100644 --- a/routers/web/repo/setting.go +++ b/routers/web/repo/setting.go @@ -227,14 +227,17 @@ func SettingsPost(ctx *context.Context) { form.MirrorPassword, _ = u.User.Password() } - err = migrations.IsMigrateURLAllowed(u.String(), ctx.Doer) + address, err := forms.ParseRemoteAddr(form.MirrorAddress, form.MirrorUsername, form.MirrorPassword) + if err == nil { + err = migrations.IsMigrateURLAllowed(address, ctx.Doer) + } if err != nil { ctx.Data["Err_MirrorAddress"] = true handleSettingRemoteAddrError(ctx, err, form) return } - if err := mirror_service.UpdateAddress(ctx, ctx.Repo.Mirror, u.String()); err != nil { + if err := mirror_service.UpdateAddress(ctx, ctx.Repo.Mirror, address); err != nil { ctx.ServerError("UpdateAddress", err) return }