Skip to content

Commit

Permalink
html: avoid panic even if unconsidered <isindex> and <template> combi…
Browse files Browse the repository at this point in the history
…nation

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>
  • Loading branch information
namusyaka authored and nigeltao committed Sep 21, 2018
1 parent 26e67e7 commit 2f5d238
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions html/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
}
Expand Down
11 changes: 11 additions & 0 deletions html/testdata/go/template.dat
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@
| <form>
| <paper-input>
| <style>

#data
<template><tBody><isindex/action=0>
#errors
#document
| <html>
| <head>
| <template>
| content
| <tbody>
| <body>

0 comments on commit 2f5d238

Please sign in to comment.