diff --git a/present/iframe.go b/present/iframe.go index 46649f0f1e..057d229585 100644 --- a/present/iframe.go +++ b/present/iframe.go @@ -23,6 +23,9 @@ func (i Iframe) TemplateName() string { return "iframe" } 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 { diff --git a/present/image.go b/present/image.go index cfa2af9ba2..84965cae54 100644 --- a/present/image.go +++ b/present/image.go @@ -23,6 +23,9 @@ func (i Image) TemplateName() string { return "image" } func parseImage(ctx *Context, fileName string, lineno int, text string) (Elem, error) { args := strings.Fields(text) + if len(args) < 2 { + return nil, fmt.Errorf("incorrect image invocation: %q", text) + } img := Image{URL: args[1]} a, err := parseArgs(fileName, lineno, args[2:]) if err != nil { diff --git a/present/video.go b/present/video.go index 913822e66b..93d93502bf 100644 --- a/present/video.go +++ b/present/video.go @@ -24,6 +24,9 @@ func (v Video) TemplateName() string { return "video" } func parseVideo(ctx *Context, fileName string, lineno int, text string) (Elem, error) { args := strings.Fields(text) + if len(args) < 3 { + return nil, fmt.Errorf("incorrect video invocation: %q", text) + } vid := Video{URL: args[1], SourceType: args[2]} a, err := parseArgs(fileName, lineno, args[3:]) if err != nil {