From 92d42b9ff15f625347a13b6aeafd04a33537ce91 Mon Sep 17 00:00:00 2001 From: Eyal Posener Date: Fri, 2 Jun 2017 14:28:38 +0300 Subject: [PATCH] present: return an error for a bad link instead of panic Change-Id: Ic41b2794268b6399bda01febafb85852f6634198 Reviewed-on: https://go-review.googlesource.com/44690 Reviewed-by: Andrew Gerrand --- present/link.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/present/link.go b/present/link.go index d4bdc04e2d..5885eb14e8 100644 --- a/present/link.go +++ b/present/link.go @@ -24,6 +24,9 @@ func (l Link) TemplateName() string { return "link" } func parseLink(ctx *Context, fileName string, lineno int, text string) (Elem, error) { args := strings.Fields(text) + if len(args) < 3 { + return nil, fmt.Errorf("link element must have at least 2 arguments") + } url, err := url.Parse(args[1]) if err != nil { return nil, err