From 2a51351d093386b311d3ef81ab6e8f0edc2d794f Mon Sep 17 00:00:00 2001 From: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com> Date: Mon, 6 Dec 2021 09:26:06 +0200 Subject: [PATCH] Improve comments and error message. --- pkg/api/plugins.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/api/plugins.go b/pkg/api/plugins.go index 0c29717fe53..217e40de95e 100644 --- a/pkg/api/plugins.go +++ b/pkg/api/plugins.go @@ -263,11 +263,12 @@ func (hs *HTTPServer) getPluginAssets(c *models.ReqContext) { return } + // prepend slash for cleaning relative paths requestedFile := filepath.Clean(filepath.Join("/", c.Params("*"))) rel, err := filepath.Rel("/", requestedFile) if err != nil { - // this should not never fail - c.JsonApiErr(500, "Relative path found", err) + // slash is prepended above therefore this is not expected to fail + c.JsonApiErr(500, "Failed to get the relative path", err) return }