]> source.dussan.org Git - gitea.git/commitdiff
Fix mirror address setting not working (#20850)
authorGary Wang <wzc782970009@gmail.com>
Sun, 21 Aug 2022 18:23:50 +0000 (02:23 +0800)
committerGitHub <noreply@github.com>
Sun, 21 Aug 2022 18:23:50 +0000 (19:23 +0100)
This patch fixes the issue that the mirror address field is ignored from the repo setting form.

routers/web/repo/setting.go

index a59824cecdb42e7cfb4770b0629ee61db93e17aa..2a04dc06a3f8c5afd6d5500fe55c95745c4942cf 100644 (file)
@@ -228,14 +228,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
                }