mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
xml: allow attributes without value in non-strict mode.
Attributes without value are commen in html and the xml parser will accept them in non-strict mode and use the attribute name as value. Thus parsing <p nowrap> as <p norwar="nowrap">. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/4601053
This commit is contained in:
parent
d81147b617
commit
7f3e109d2f
2 changed files with 41 additions and 9 deletions
|
|
@ -659,17 +659,22 @@ func (p *Parser) RawToken() (Token, os.Error) {
|
|||
return nil, p.err
|
||||
}
|
||||
if b != '=' {
|
||||
p.err = p.syntaxError("attribute name without = in element")
|
||||
return nil, p.err
|
||||
if p.Strict {
|
||||
p.err = p.syntaxError("attribute name without = in element")
|
||||
return nil, p.err
|
||||
} else {
|
||||
p.ungetc(b)
|
||||
a.Value = a.Name.Local
|
||||
}
|
||||
} else {
|
||||
p.space()
|
||||
data := p.attrval()
|
||||
if data == nil {
|
||||
return nil, p.err
|
||||
}
|
||||
a.Value = string(data)
|
||||
}
|
||||
p.space()
|
||||
data := p.attrval()
|
||||
if data == nil {
|
||||
return nil, p.err
|
||||
}
|
||||
a.Value = string(data)
|
||||
}
|
||||
|
||||
if empty {
|
||||
p.needClose = true
|
||||
p.toClose = name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue