Fix index out of range in headline priority parsing

fuzzed - counting is hard...
This commit is contained in:
Niklas Fasching 2019-10-27 15:24:24 +01:00
parent 20970ec872
commit f69b043136
4 changed files with 28 additions and 3 deletions

View file

@ -56,7 +56,7 @@ func (d *Document) parseHeadline(i int, parentStop stopFn) (int, Node) {
}
}
if len(text) >= 3 && text[0:2] == "[#" && strings.Contains("ABC", text[2:3]) && text[3] == ']' {
if len(text) >= 4 && text[0:2] == "[#" && strings.Contains("ABC", text[2:3]) && text[3] == ']' {
headline.Priority = text[2:3]
text = strings.TrimSpace(text[4:])
}