mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
encoding/xml: parse comments in DOCTYPE
R=rsc, n13m3y3r CC=golang-dev https://golang.org/cl/6330061
This commit is contained in:
parent
2785f9528e
commit
a11b748fa2
2 changed files with 63 additions and 1 deletions
|
|
@ -621,3 +621,36 @@ func TestProcInstEncoding(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that directives with comments include the complete
|
||||
// text of any nested directives.
|
||||
|
||||
var directivesWithCommentsInput = `
|
||||
<!DOCTYPE [<!-- a comment --><!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">]>
|
||||
<!DOCTYPE [<!ENTITY go "Golang"><!-- a comment-->]>
|
||||
<!DOCTYPE <!-> <!> <!----> <!-->--> <!--->--> [<!ENTITY go "Golang"><!-- a comment-->]>
|
||||
`
|
||||
|
||||
var directivesWithCommentsTokens = []Token{
|
||||
CharData("\n"),
|
||||
Directive(`DOCTYPE [<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">]`),
|
||||
CharData("\n"),
|
||||
Directive(`DOCTYPE [<!ENTITY go "Golang">]`),
|
||||
CharData("\n"),
|
||||
Directive(`DOCTYPE <!-> <!> [<!ENTITY go "Golang">]`),
|
||||
CharData("\n"),
|
||||
}
|
||||
|
||||
func TestDirectivesWithComments(t *testing.T) {
|
||||
d := NewDecoder(strings.NewReader(directivesWithCommentsInput))
|
||||
|
||||
for i, want := range directivesWithCommentsTokens {
|
||||
have, err := d.Token()
|
||||
if err != nil {
|
||||
t.Fatalf("token %d: unexpected error: %s", i, err)
|
||||
}
|
||||
if !reflect.DeepEqual(have, want) {
|
||||
t.Errorf("token %d = %#v want %#v", i, have, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue