Fix explicit line break parsing

It's possible for the input to end right after the explicit line break,
i.e. after the second \. This currently leads to an out of range index into
input (as the for loop starts with start+2 and [start:start+1] is the \\).
This commit is contained in:
Niklas Fasching 2019-01-12 20:03:26 +01:00
parent 00d5a9cdd2
commit da99094e20
4 changed files with 7 additions and 4 deletions

View file

@ -129,7 +129,7 @@ func (d *Document) parseLineBreak(input string, start int) (int, Node) {
}
func (d *Document) parseExplicitLineBreak(input string, start int) (int, Node) {
if start == 0 || input[start-1] == '\n' || start+1 >= len(input) || input[start+1] != '\\' {
if start == 0 || input[start-1] == '\n' || start+2 >= len(input) || input[start+1] != '\\' {
return 0, nil
}
for i := start + 2; unicode.IsSpace(rune(input[i])); i++ {