From beabc8d998249ecc5dd522d696dc6233a29131c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 30 Oct 2020 10:14:08 +0100 Subject: modules: Allow absolute paths for project imports Fixes #7910 --- modules/client.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'modules/client.go') diff --git a/modules/client.go b/modules/client.go index c6f43298d..7d2175c94 100644 --- a/modules/client.go +++ b/modules/client.go @@ -614,10 +614,19 @@ func (c *Client) shouldVendor(path string) bool { } func (c *Client) createThemeDirname(modulePath string, isProjectMod bool) (string, error) { + invalid := errors.Errorf("invalid module path %q; must be relative to themesDir when defined outside of the project", modulePath) + modulePath = filepath.Clean(modulePath) + if filepath.IsAbs(modulePath) { + if isProjectMod { + return modulePath, nil + } + return "", invalid + } + 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 "", invalid } return moduleDir, nil } -- cgit v1.2.3