diff options
author | bep <bjorn.erik.pedersen@gmail.com> | 2014-12-10 18:48:51 +0300 |
---|---|---|
committer | bep <bjorn.erik.pedersen@gmail.com> | 2014-12-10 22:32:39 +0300 |
commit | e6541c45ab1a3d15acd1beea73df5d17d08c7769 (patch) | |
tree | dc366d6388e24ae2623afdac8f0025a7112d6299 /tpl | |
parent | 9f77f93071d836a35b0078d1b349968abddb4a18 (diff) |
ERROR-log on symbolic links
filepath.Walk does not follow symbolic links.
There's no easy fix for that outside of Go, so the best we can do for now is to give notice to the end user by ERROR log statements.
This commit also fixes a related panic situation in GenerateTemplateNameFrom when the layout dir was a symbolic link.
Fixes #283
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/template.go | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/tpl/template.go b/tpl/template.go index 5010af9ae..d057f174d 100644 --- a/tpl/template.go +++ b/tpl/template.go @@ -16,6 +16,11 @@ package tpl import ( "bytes" "errors" + "github.com/eknkc/amber" + "github.com/spf13/cast" + "github.com/spf13/hugo/helpers" + jww "github.com/spf13/jwalterweatherman" + "github.com/yosssi/ace" "html" "html/template" "io" @@ -25,12 +30,6 @@ import ( "reflect" "strconv" "strings" - - "github.com/eknkc/amber" - "github.com/spf13/cast" - "github.com/spf13/hugo/helpers" - jww "github.com/spf13/jwalterweatherman" - "github.com/yosssi/ace" ) var localTemplates *template.Template @@ -703,7 +702,8 @@ func (t *GoHtmlTemplate) AddTemplateFile(name, path string) error { } func (t *GoHtmlTemplate) GenerateTemplateNameFrom(base, path string) string { - return filepath.ToSlash(path[len(base)+1:]) + name, _ := filepath.Rel(base, path) + return filepath.ToSlash(name) } func ignoreDotFile(path string) bool { @@ -716,6 +716,11 @@ func (t *GoHtmlTemplate) loadTemplates(absPath string, prefix string) { return nil } + if fi.Mode()&os.ModeSymlink == os.ModeSymlink { + jww.ERROR.Printf("Symbolic links not supported, skipping '%s'", absPath) + return nil + } + if !fi.IsDir() { if ignoreDotFile(path) { return nil |