From 173187e2633f3fc037c83e1e3de2902ae3c93b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Thu, 29 Oct 2020 17:14:04 +0100 Subject: Add module.replacements Fixes #7904 Fixes #7908 --- modules/client.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules/client.go') diff --git a/modules/client.go b/modules/client.go index d07483d36..c6f43298d 100644 --- a/modules/client.go +++ b/modules/client.go @@ -613,6 +613,15 @@ func (c *Client) shouldVendor(path string) bool { return c.noVendor == nil || !c.noVendor.Match(path) } +func (c *Client) createThemeDirname(modulePath string, isProjectMod bool) (string, error) { + modulePath = filepath.Clean(modulePath) + moduleDir := filepath.Join(c.ccfg.ThemesDir, modulePath) + if !isProjectMod && !strings.HasPrefix(moduleDir, c.ccfg.ThemesDir) { + return "", errors.Errorf("invalid module path %q; must be relative to themesDir when defined outside of the project", modulePath) + } + return moduleDir, nil +} + // ClientConfig configures the module Client. type ClientConfig struct { Fs afero.Fs -- cgit v1.2.3