Update dependencies
This commit is contained in:
61
vendor/golang.org/x/net/html/parse.go
generated
vendored
61
vendor/golang.org/x/net/html/parse.go
generated
vendored
@@ -136,7 +136,7 @@ func (p *parser) indexOfElementInScope(s scope, matchTags ...a.Atom) int {
|
||||
return -1
|
||||
}
|
||||
default:
|
||||
panic("unreachable")
|
||||
panic(fmt.Sprintf("html: internal error: indexOfElementInScope unknown scope: %d", s))
|
||||
}
|
||||
}
|
||||
switch s {
|
||||
@@ -179,7 +179,7 @@ func (p *parser) clearStackToContext(s scope) {
|
||||
return
|
||||
}
|
||||
default:
|
||||
panic("unreachable")
|
||||
panic(fmt.Sprintf("html: internal error: clearStackToContext unknown scope: %d", s))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -231,7 +231,14 @@ func (p *parser) addChild(n *Node) {
|
||||
}
|
||||
|
||||
if n.Type == ElementNode {
|
||||
p.oe = append(p.oe, n)
|
||||
p.insertOpenElement(n)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *parser) insertOpenElement(n *Node) {
|
||||
p.oe = append(p.oe, n)
|
||||
if len(p.oe) > 512 {
|
||||
panic("html: open stack of elements exceeds 512 nodes")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -810,7 +817,7 @@ func afterHeadIM(p *parser) bool {
|
||||
p.im = inFramesetIM
|
||||
return true
|
||||
case a.Base, a.Basefont, a.Bgsound, a.Link, a.Meta, a.Noframes, a.Script, a.Style, a.Template, a.Title:
|
||||
p.oe = append(p.oe, p.head)
|
||||
p.insertOpenElement(p.head)
|
||||
defer p.oe.remove(p.head)
|
||||
return inHeadIM(p)
|
||||
case a.Head:
|
||||
@@ -924,7 +931,7 @@ func inBodyIM(p *parser) bool {
|
||||
p.addElement()
|
||||
p.im = inFramesetIM
|
||||
return true
|
||||
case a.Address, a.Article, a.Aside, a.Blockquote, a.Center, a.Details, a.Dialog, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Main, a.Menu, a.Nav, a.Ol, a.P, a.Section, a.Summary, a.Ul:
|
||||
case a.Address, a.Article, a.Aside, a.Blockquote, a.Center, a.Details, a.Dialog, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Main, a.Menu, a.Nav, a.Ol, a.P, a.Search, a.Section, a.Summary, a.Ul:
|
||||
p.popUntil(buttonScope, a.P)
|
||||
p.addElement()
|
||||
case a.H1, a.H2, a.H3, a.H4, a.H5, a.H6:
|
||||
@@ -1136,7 +1143,7 @@ func inBodyIM(p *parser) bool {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
case a.Address, a.Article, a.Aside, a.Blockquote, a.Button, a.Center, a.Details, a.Dialog, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Listing, a.Main, a.Menu, a.Nav, a.Ol, a.Pre, a.Section, a.Summary, a.Ul:
|
||||
case a.Address, a.Article, a.Aside, a.Blockquote, a.Button, a.Center, a.Details, a.Dialog, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Listing, a.Main, a.Menu, a.Nav, a.Ol, a.Pre, a.Search, a.Section, a.Summary, a.Ul:
|
||||
p.popUntil(defaultScope, p.tok.DataAtom)
|
||||
case a.Form:
|
||||
if p.oe.contains(a.Template) {
|
||||
@@ -1678,7 +1685,7 @@ func inTableBodyIM(p *parser) bool {
|
||||
return inTableIM(p)
|
||||
}
|
||||
|
||||
// Section 12.2.6.4.14.
|
||||
// Section 13.2.6.4.14.
|
||||
func inRowIM(p *parser) bool {
|
||||
switch p.tok.Type {
|
||||
case StartTagToken:
|
||||
@@ -1690,7 +1697,9 @@ func inRowIM(p *parser) bool {
|
||||
p.im = inCellIM
|
||||
return true
|
||||
case a.Caption, a.Col, a.Colgroup, a.Tbody, a.Tfoot, a.Thead, a.Tr:
|
||||
if p.popUntil(tableScope, a.Tr) {
|
||||
if p.elementInScope(tableScope, a.Tr) {
|
||||
p.clearStackToContext(tableRowScope)
|
||||
p.oe.pop()
|
||||
p.im = inTableBodyIM
|
||||
return false
|
||||
}
|
||||
@@ -1700,22 +1709,28 @@ func inRowIM(p *parser) bool {
|
||||
case EndTagToken:
|
||||
switch p.tok.DataAtom {
|
||||
case a.Tr:
|
||||
if p.popUntil(tableScope, a.Tr) {
|
||||
if p.elementInScope(tableScope, a.Tr) {
|
||||
p.clearStackToContext(tableRowScope)
|
||||
p.oe.pop()
|
||||
p.im = inTableBodyIM
|
||||
return true
|
||||
}
|
||||
// Ignore the token.
|
||||
return true
|
||||
case a.Table:
|
||||
if p.popUntil(tableScope, a.Tr) {
|
||||
if p.elementInScope(tableScope, a.Tr) {
|
||||
p.clearStackToContext(tableRowScope)
|
||||
p.oe.pop()
|
||||
p.im = inTableBodyIM
|
||||
return false
|
||||
}
|
||||
// Ignore the token.
|
||||
return true
|
||||
case a.Tbody, a.Tfoot, a.Thead:
|
||||
if p.elementInScope(tableScope, p.tok.DataAtom) {
|
||||
p.parseImpliedToken(EndTagToken, a.Tr, a.Tr.String())
|
||||
if p.elementInScope(tableScope, p.tok.DataAtom) && p.elementInScope(tableScope, a.Tr) {
|
||||
p.clearStackToContext(tableRowScope)
|
||||
p.oe.pop()
|
||||
p.im = inTableBodyIM
|
||||
return false
|
||||
}
|
||||
// Ignore the token.
|
||||
@@ -2222,16 +2237,20 @@ func parseForeignContent(p *parser) bool {
|
||||
p.acknowledgeSelfClosingTag()
|
||||
}
|
||||
case EndTagToken:
|
||||
if strings.EqualFold(p.oe[len(p.oe)-1].Data, p.tok.Data) {
|
||||
p.oe = p.oe[:len(p.oe)-1]
|
||||
return true
|
||||
}
|
||||
for i := len(p.oe) - 1; i >= 0; i-- {
|
||||
if p.oe[i].Namespace == "" {
|
||||
return p.im(p)
|
||||
}
|
||||
if strings.EqualFold(p.oe[i].Data, p.tok.Data) {
|
||||
p.oe = p.oe[:i]
|
||||
return true
|
||||
}
|
||||
if i > 0 && p.oe[i-1].Namespace == "" {
|
||||
break
|
||||
}
|
||||
}
|
||||
return true
|
||||
return p.im(p)
|
||||
default:
|
||||
// Ignore the token.
|
||||
}
|
||||
@@ -2312,9 +2331,13 @@ func (p *parser) parseCurrentToken() {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *parser) parse() error {
|
||||
func (p *parser) parse() (err error) {
|
||||
defer func() {
|
||||
if panicErr := recover(); panicErr != nil {
|
||||
err = fmt.Errorf("%s", panicErr)
|
||||
}
|
||||
}()
|
||||
// Iterate until EOF. Any other error will cause an early return.
|
||||
var err error
|
||||
for err != io.EOF {
|
||||
// CDATA sections are allowed only in foreign content.
|
||||
n := p.oe.top()
|
||||
@@ -2343,6 +2366,8 @@ func (p *parser) parse() error {
|
||||
// <tag>s. Conversely, explicit <tag>s in r's data can be silently dropped,
|
||||
// with no corresponding node in the resulting tree.
|
||||
//
|
||||
// Parse will reject HTML that is nested deeper than 512 elements.
|
||||
//
|
||||
// The input is assumed to be UTF-8 encoded.
|
||||
func Parse(r io.Reader) (*Node, error) {
|
||||
return ParseWithOptions(r)
|
||||
|
||||
Reference in New Issue
Block a user