diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-03-13 02:41:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-13 02:41:40 +0100 |
commit | be5738243c2ab9e3bd21a0b3d581761d73007883 (patch) | |
tree | 0d5bf3066d6284851e1579953d518a5351f19d54 /routers/repo/setting.go | |
parent | Add myself to maintainers (#1229) (diff) | |
download | forgejo-be5738243c2ab9e3bd21a0b3d581761d73007883.tar.xz forgejo-be5738243c2ab9e3bd21a0b3d581761d73007883.zip |
fix repo settings external tracker failed and check external urls (#1215)
Diffstat (limited to '')
-rw-r--r-- | routers/repo/setting.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 91068d242a..fb6d68ad9b 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -72,6 +72,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { err := models.NewRepoRedirect(ctx.Repo.Owner.ID, repo.ID, repo.Name, newRepoName) if err != nil { ctx.Handle(500, "NewRepoRedirect", err) + return } log.Trace("Repository name changed: %s/%s -> %s", ctx.Repo.Owner.Name, repo.Name, newRepoName) @@ -151,6 +152,12 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { if form.EnableWiki { if form.EnableExternalWiki { + if !strings.HasPrefix(form.ExternalWikiURL, "http://") && !strings.HasPrefix(form.ExternalWikiURL, "https://") { + ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error")) + ctx.Redirect(repo.Link() + "/settings") + return + } + units = append(units, models.RepoUnit{ RepoID: repo.ID, Type: models.UnitTypeExternalWiki, @@ -171,10 +178,15 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { if form.EnableIssues { if form.EnableExternalTracker { + if !strings.HasPrefix(form.ExternalTrackerURL, "http://") && !strings.HasPrefix(form.ExternalTrackerURL, "https://") { + ctx.Flash.Error(ctx.Tr("repo.settings.external_tracker_url_error")) + ctx.Redirect(repo.Link() + "/settings") + return + } units = append(units, models.RepoUnit{ RepoID: repo.ID, - Type: models.UnitTypeExternalWiki, - Index: int(models.UnitTypeExternalWiki), + Type: models.UnitTypeExternalTracker, + Index: int(models.UnitTypeExternalTracker), Config: &models.ExternalTrackerConfig{ ExternalTrackerURL: form.ExternalTrackerURL, ExternalTrackerFormat: form.TrackerURLFormat, |