From a43fc9ad17d4337dd26b9b8d867470ca8c548b41 Mon Sep 17 00:00:00 2001 From: ᴜɴᴋɴᴡᴏɴ Date: Sat, 21 Mar 2020 00:12:38 +0800 Subject: ipynb: sanitize rendered HTML (#5996) * ipynb: sanitize rendered HTML Fixes #5170 * Remove hardcode URL * Add tests --- internal/cmd/web.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'internal/cmd') diff --git a/internal/cmd/web.go b/internal/cmd/web.go index 1d78e4a6..fb7be88b 100644 --- a/internal/cmd/web.go +++ b/internal/cmd/web.go @@ -29,6 +29,7 @@ import ( "gopkg.in/macaron.v1" log "unknwon.dev/clog/v2" + "gogs.io/gogs/internal/app" "gogs.io/gogs/internal/assets/public" "gogs.io/gogs/internal/assets/templates" "gogs.io/gogs/internal/conf" @@ -665,16 +666,15 @@ func runWeb(c *cli.Context) error { apiv1.RegisterRoutes(m) }, ignSignIn) + // *************************** + // ----- Internal routes ----- + // *************************** m.Group("/-", func() { - if conf.Prometheus.Enabled { - m.Get("/metrics", func(c *context.Context) { - if !conf.Prometheus.EnableBasicAuth { - return - } + m.Get("/metrics", app.MetricsFilter(), promhttp.Handler()) // "/-/metrics" - c.RequireBasicAuth(conf.Prometheus.BasicAuthUsername, conf.Prometheus.BasicAuthPassword) - }, promhttp.Handler()) - } + m.Group("/api", func() { + m.Post("/sanitize_ipynb", app.SanitizeIpynb()) // "/-/api/sanitize_ipynb" + }) }) // robots.txt -- cgit v1.2.3