Skip to content

Commit afd1edf

Browse files
namusyakanigeltao
authored andcommitted
html: drop <isindex> and <command> specific handlings
This commit also adds remaining tests to follow up on golang.org/cl/205617 Change-Id: I8b155f9f605c6a0eb8745c32f5e785f5b4bc1c7e Reviewed-on: https://go-review.googlesource.com/c/net/+/208937 Run-TryBot: Kunpei Sakai <namusyaka@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Nigel Tao <nigeltao@golang.org>
1 parent 5ee1b9f commit afd1edf

File tree

8 files changed

+296
-166
lines changed

8 files changed

+296
-166
lines changed

html/const.go

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ var isSpecialElementMap = map[string]bool{
5252
"iframe": true,
5353
"img": true,
5454
"input": true,
55-
"isindex": true, // The 'isindex' element has been removed, but keep it for backwards compatibility.
5655
"keygen": true,
5756
"li": true,
5857
"link": true,

html/parse.go

+2-49
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ func inHeadIM(p *parser) bool {
625625
switch p.tok.DataAtom {
626626
case a.Html:
627627
return inBodyIM(p)
628-
case a.Base, a.Basefont, a.Bgsound, a.Command, a.Link, a.Meta:
628+
case a.Base, a.Basefont, a.Bgsound, a.Link, a.Meta:
629629
p.addElement()
630630
p.oe.pop()
631631
p.acknowledgeSelfClosingTag()
@@ -855,7 +855,7 @@ func inBodyIM(p *parser) bool {
855855
return true
856856
}
857857
copyAttributes(p.oe[0], p.tok)
858-
case a.Base, a.Basefont, a.Bgsound, a.Command, a.Link, a.Meta, a.Noframes, a.Script, a.Style, a.Template, a.Title:
858+
case a.Base, a.Basefont, a.Bgsound, a.Link, a.Meta, a.Noframes, a.Script, a.Style, a.Template, a.Title:
859859
return inHeadIM(p)
860860
case a.Body:
861861
if p.oe.contains(a.Template) {
@@ -1014,53 +1014,6 @@ func inBodyIM(p *parser) bool {
10141014
p.tok.DataAtom = a.Img
10151015
p.tok.Data = a.Img.String()
10161016
return false
1017-
case a.Isindex:
1018-
if p.form != nil {
1019-
// Ignore the token.
1020-
return true
1021-
}
1022-
action := ""
1023-
prompt := "This is a searchable index. Enter search keywords: "
1024-
attr := []Attribute{{Key: "name", Val: "isindex"}}
1025-
for _, t := range p.tok.Attr {
1026-
switch t.Key {
1027-
case "action":
1028-
action = t.Val
1029-
case "name":
1030-
// Ignore the attribute.
1031-
case "prompt":
1032-
prompt = t.Val
1033-
default:
1034-
attr = append(attr, t)
1035-
}
1036-
}
1037-
p.acknowledgeSelfClosingTag()
1038-
p.popUntil(buttonScope, a.P)
1039-
p.parseImpliedToken(StartTagToken, a.Form, a.Form.String())
1040-
if p.form == nil {
1041-
// NOTE: The 'isindex' element has been removed,
1042-
// and the 'template' element has not been designed to be
1043-
// collaborative with the index element.
1044-
//
1045-
// Ignore the token.
1046-
return true
1047-
}
1048-
if action != "" {
1049-
p.form.Attr = []Attribute{{Key: "action", Val: action}}
1050-
}
1051-
p.parseImpliedToken(StartTagToken, a.Hr, a.Hr.String())
1052-
p.parseImpliedToken(StartTagToken, a.Label, a.Label.String())
1053-
p.addText(prompt)
1054-
p.addChild(&Node{
1055-
Type: ElementNode,
1056-
DataAtom: a.Input,
1057-
Data: a.Input.String(),
1058-
Attr: attr,
1059-
})
1060-
p.oe.pop()
1061-
p.parseImpliedToken(EndTagToken, a.Label, a.Label.String())
1062-
p.parseImpliedToken(StartTagToken, a.Hr, a.Hr.String())
1063-
p.parseImpliedToken(EndTagToken, a.Form, a.Form.String())
10641017
case a.Textarea:
10651018
p.addElement()
10661019
p.setOriginalIM()

html/render.go

+15-16
Original file line numberDiff line numberDiff line change
@@ -252,20 +252,19 @@ func writeQuoted(w writer, s string) error {
252252
// Section 12.1.2, "Elements", gives this list of void elements. Void elements
253253
// are those that can't have any contents.
254254
var voidElements = map[string]bool{
255-
"area": true,
256-
"base": true,
257-
"br": true,
258-
"col": true,
259-
"command": true,
260-
"embed": true,
261-
"hr": true,
262-
"img": true,
263-
"input": true,
264-
"keygen": true,
265-
"link": true,
266-
"meta": true,
267-
"param": true,
268-
"source": true,
269-
"track": true,
270-
"wbr": true,
255+
"area": true,
256+
"base": true,
257+
"br": true,
258+
"col": true,
259+
"embed": true,
260+
"hr": true,
261+
"img": true,
262+
"input": true,
263+
"keygen": true,
264+
"link": true,
265+
"meta": true,
266+
"param": true,
267+
"source": true,
268+
"track": true,
269+
"wbr": true,
271270
}

html/testdata/go/template.dat

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
| <template>
2222
| content
2323
| <tbody>
24+
| <isindex>
25+
| action="0"
2426
| <body>
2527

2628
#data

html/testdata/webkit/isindex.dat

+24-15
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,49 @@
11
#data
22
<isindex>
33
#errors
4+
(1,9): expected-doctype-but-got-start-tag
5+
(1,9): expected-closing-tag-but-got-eof
46
#document
57
| <html>
68
| <head>
79
| <body>
8-
| <form>
9-
| <hr>
10-
| <label>
11-
| "This is a searchable index. Enter search keywords: "
12-
| <input>
13-
| name="isindex"
14-
| <hr>
10+
| <isindex>
1511

1612
#data
1713
<isindex name="A" action="B" prompt="C" foo="D">
1814
#errors
15+
(1,48): expected-doctype-but-got-start-tag
16+
(1,48): expected-closing-tag-but-got-eof
1917
#document
2018
| <html>
2119
| <head>
2220
| <body>
23-
| <form>
21+
| <isindex>
2422
| action="B"
25-
| <hr>
26-
| <label>
27-
| "C"
28-
| <input>
29-
| foo="D"
30-
| name="isindex"
31-
| <hr>
23+
| foo="D"
24+
| name="A"
25+
| prompt="C"
3226

3327
#data
3428
<form><isindex>
3529
#errors
30+
(1,6): expected-doctype-but-got-start-tag
31+
(1,15): expected-closing-tag-but-got-eof
3632
#document
3733
| <html>
3834
| <head>
3935
| <body>
4036
| <form>
37+
| <isindex>
38+
39+
#data
40+
<!doctype html><isindex>x</isindex>x
41+
#errors
42+
#document
43+
| <!DOCTYPE html>
44+
| <html>
45+
| <head>
46+
| <body>
47+
| <isindex>
48+
| "x"
49+
| "x"

0 commit comments

Comments
 (0)