html: avoid panic even if unconsidered <isindex> and <template> combination

The <isindex> element has been removed from the spec so that the
<template> element doesn't cover it.
To avoid panic, this commit adds ignoring code as a workaround.

Fixes golang/go#27704

Change-Id: I847391389285df2fc0eb6a795f8c93b481cdebac
Reviewed-on: https://go-review.googlesource.com/136575
Reviewed-by: Nigel Tao <nigeltao@golang.org>
diff --git a/html/parse.go b/html/parse.go
index 091fb0d..63ac179 100644
--- a/html/parse.go
+++ b/html/parse.go
@@ -984,6 +984,14 @@
 			p.acknowledgeSelfClosingTag()
 			p.popUntil(buttonScope, a.P)
 			p.parseImpliedToken(StartTagToken, a.Form, a.Form.String())
+			if p.form == nil {
+				// NOTE: The 'isindex' element has been removed,
+				// and the 'template' element has not been designed to be
+				// collaborative with the index element.
+				//
+				// Ignore the token.
+				return true
+			}
 			if action != "" {
 				p.form.Attr = []Attribute{{Key: "action", Val: action}}
 			}
diff --git a/html/testdata/go/template.dat b/html/testdata/go/template.dat
index a0a525b..b6f2a8d 100644
--- a/html/testdata/go/template.dat
+++ b/html/testdata/go/template.dat
@@ -11,3 +11,14 @@
 |         <form>
 |           <paper-input>
 |         <style>
+
+#data
+<template><tBody><isindex/action=0>
+#errors
+#document
+| <html>
+|   <head>
+|     <template>
+|       content
+|         <tbody>
+|   <body>