aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/index/index.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/index/index.go')
-rw-r--r--pkg/index/index.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/pkg/index/index.go b/pkg/index/index.go
index 15a5e86..5d23e14 100644
--- a/pkg/index/index.go
+++ b/pkg/index/index.go
@@ -329,7 +329,14 @@ func ParseDoc(path string) (*Document, error) {
}
doc.FileTime = info.ModTime()
- if err := yaml.NewDecoder(f).Decode(doc); err != nil {
+ pos := yamlHeaderPos(f)
+ f.Seek(0, io.SeekStart)
+ if pos < 0 {
+ return nil, fmt.Errorf("Can't find YAML header in %s", path)
+ }
+
+ // FIXME: decoder reads past yaml header into document
+ if err := yaml.NewDecoder(io.LimitReader(f, pos)).Decode(doc); err != nil {
return nil, errors.Join(ErrHeaderParse, err)
}