Handle malformed :PROPERTY: drawers

Until now we'd get index out of range errors trying to index into the match if
:PROPERTIES: was followed by a non-property. Thanks fuzz
This commit is contained in:
Niklas Fasching 2019-09-28 15:08:53 +02:00
parent 76b157b8ce
commit adeeb9235d
5 changed files with 28 additions and 0 deletions

View file

@ -67,6 +67,9 @@ func (d *Document) parsePropertyDrawer(i int, parentStop stopFn) (int, Node) {
}
for ; !stop(d, i); i++ {
m := propertyRegexp.FindStringSubmatch(d.tokens[i].matches[0])
if m == nil {
return 0, nil
}
k, v := strings.ToUpper(m[2]), strings.TrimSpace(m[4])
drawer.Properties = append(drawer.Properties, []string{k, v})
}