present: check if too few arguments to image, iframe, or video
Previously, using incorrect syntax for one of image, iframe, or video
functions caused an index out of range panic. Add a check to prevent
the panic and return an error instead.
Fixes golang/go#35142
Change-Id: Ifffb4cc5daded5331d617a3db7cad84e37abadc8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/203477
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
diff --git a/present/iframe.go b/present/iframe.go
index 46649f0..057d229 100644
--- a/present/iframe.go
+++ b/present/iframe.go
@@ -23,6 +23,9 @@
func parseIframe(ctx *Context, fileName string, lineno int, text string) (Elem, error) {
args := strings.Fields(text)
+ if len(args) < 2 {
+ return nil, fmt.Errorf("incorrect iframe invocation: %q", text)
+ }
i := Iframe{URL: args[1]}
a, err := parseArgs(fileName, lineno, args[2:])
if err != nil {