Преглед на файлове

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>
Kunpei Sakai преди 7 години
родител
ревизия
2f5d238892
променени са 2 файла, в които са добавени 19 реда и са изтрити 0 реда
  1. 8 0
      html/parse.go
  2. 11 0
      html/testdata/go/template.dat

+ 8 - 0
html/parse.go

@@ -984,6 +984,14 @@ func inBodyIM(p *parser) bool {
 			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}}
 			}

+ 11 - 0
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>