From 36436a4c5977a23e9260f19b248f1903ecb05795 Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Thu, 20 Dec 2018 15:20:23 +0100 Subject: [PATCH] Fix inline parser unanchored regexps fuzzed --- org/inline.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org/inline.go b/org/inline.go index 86740f3..a678072 100644 --- a/org/inline.go +++ b/org/inline.go @@ -175,7 +175,7 @@ func (d *Document) parseStatisticToken(input string, start int) (int, Node) { } func (d *Document) parseAutoLink(input string, start int) (int, int, Node) { - if !d.AutoLink || len(input[start:]) < 3 || input[start+1] != '/' || input[start+2] != '/' { + if !d.AutoLink || start == 0 || len(input[start:]) < 3 || input[start:start+3] != "://" { return 0, 0, nil } protocolStart, protocol := start-1, "" @@ -197,10 +197,10 @@ func (d *Document) parseAutoLink(input string, start int) (int, int, Node) { } func (d *Document) parseRegularLink(input string, start int) (int, Node) { - if len(input[start:]) < 2 || input[start+1] != '[' || input[start+2] == '[' { + input = input[start:] + if len(input) < 3 || input[1] != '[' || input[2] == '[' { return 0, nil } - input = input[start:] end := strings.Index(input, "]]") if end == -1 { return 0, nil