From 3ade4d9b2bfa6ae84a1ded932907a53060565575 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 21 Aug 2024 09:54:55 +0800 Subject: [PATCH] Don't return 500 if mirror url contains special chars (#31859) Fix #31640 (cherry picked from commit d158472a5a9ead8052095b153821a9f26c294452) --- routers/web/repo/setting/setting.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/routers/web/repo/setting/setting.go b/routers/web/repo/setting/setting.go index 76539b9fa2..9a989d0c14 100644 --- a/routers/web/repo/setting/setting.go +++ b/routers/web/repo/setting/setting.go @@ -480,7 +480,8 @@ func SettingsPost(ctx *context.Context) { } remoteAddress, err := util.SanitizeURL(address) if err != nil { - ctx.ServerError("SanitizeURL", err) + ctx.Data["Err_MirrorAddress"] = true + handleSettingRemoteAddrError(ctx, err, form) return } pullMirror.RemoteAddress = remoteAddress @@ -661,7 +662,8 @@ func SettingsPost(ctx *context.Context) { remoteAddress, err := util.SanitizeURL(address) if err != nil { - ctx.ServerError("SanitizeURL", err) + ctx.Data["Err_PushMirrorAddress"] = true + handleSettingRemoteAddrError(ctx, err, form) return }