зеркало из https://github.com/golang/net.git
html: handle equals sign before attribute
Apply the correct normalization when an equals sign appears before an attribute name (e.g. '<tag =>' -> '<tag =="">'), per WHATWG 13.2.5.32. Change-Id: Id21b428bd86117dd073c502767386bc718a3fb7b Reviewed-on: https://go-review.googlesource.com/c/net/+/488695 Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Nigel Tao <nigeltao@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Reviewed-by: Nigel Tao (INACTIVE; USE @golang.org INSTEAD) <nigeltao@google.com>
This commit is contained in:
Родитель
f5464ddb68
Коммит
4050002696
|
@ -913,7 +913,14 @@ func (z *Tokenizer) readTagAttrKey() {
|
|||
case ' ', '\n', '\r', '\t', '\f', '/':
|
||||
z.pendingAttr[0].end = z.raw.end - 1
|
||||
return
|
||||
case '=', '>':
|
||||
case '=':
|
||||
if z.pendingAttr[0].start+1 == z.raw.end {
|
||||
// WHATWG 13.2.5.32, if we see an equals sign before the attribute name
|
||||
// begins, we treat it as a character in the attribute name and continue.
|
||||
continue
|
||||
}
|
||||
fallthrough
|
||||
case '>':
|
||||
z.raw.end--
|
||||
z.pendingAttr[0].end = z.raw.end
|
||||
return
|
||||
|
|
|
@ -590,6 +590,17 @@ var tokenTests = []tokenTest{
|
|||
`<p id=can't><p id=won't>`,
|
||||
`<p id="can't">$<p id="won't">`,
|
||||
},
|
||||
// WHATWG 13.2.5.32 equals sign before attribute name state
|
||||
{
|
||||
"equals sign before attribute name",
|
||||
`<p =>`,
|
||||
`<p =="">`,
|
||||
},
|
||||
{
|
||||
"equals sign before attribute name, extra cruft",
|
||||
`<p =asd>`,
|
||||
`<p =asd="">`,
|
||||
},
|
||||
}
|
||||
|
||||
func TestTokenizer(t *testing.T) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче