mirror of
https://github.com/golang/go
synced 2024-11-22 04:24:39 -07:00
html: on EOF in a comment, ignore final dashes (up to 2)
Pass tests2.dat, test 57: <!DOCTYPE html><!--x-- | <!DOCTYPE html> | <!-- x --> | <html> | <head> | <body> Also pass test 58: <!DOCTYPE html><table><tr><td></p></table> R=nigeltao CC=golang-dev https://golang.org/cl/5436048
This commit is contained in:
parent
79bce499a3
commit
57ed39fd3b
@ -134,7 +134,7 @@ func TestParser(t *testing.T) {
|
||||
}{
|
||||
// TODO(nigeltao): Process all the test cases from all the .dat files.
|
||||
{"tests1.dat", -1},
|
||||
{"tests2.dat", 57},
|
||||
{"tests2.dat", 59},
|
||||
{"tests3.dat", 0},
|
||||
}
|
||||
for _, tf := range testFiles {
|
||||
|
@ -289,7 +289,11 @@ func (z *Tokenizer) readComment() {
|
||||
for dashCount := 2; ; {
|
||||
c := z.readByte()
|
||||
if z.err != nil {
|
||||
z.data.end = z.raw.end
|
||||
// Ignore up to two dashes at EOF.
|
||||
if dashCount > 2 {
|
||||
dashCount = 2
|
||||
}
|
||||
z.data.end = z.raw.end - dashCount
|
||||
return
|
||||
}
|
||||
switch c {
|
||||
|
@ -325,6 +325,26 @@ var tokenTests = []tokenTest{
|
||||
},
|
||||
{
|
||||
"comment9",
|
||||
"a<!--z-",
|
||||
"a$<!--z-->",
|
||||
},
|
||||
{
|
||||
"comment10",
|
||||
"a<!--z--",
|
||||
"a$<!--z-->",
|
||||
},
|
||||
{
|
||||
"comment11",
|
||||
"a<!--z---",
|
||||
"a$<!--z--->",
|
||||
},
|
||||
{
|
||||
"comment12",
|
||||
"a<!--z----",
|
||||
"a$<!--z---->",
|
||||
},
|
||||
{
|
||||
"comment13",
|
||||
"a<!--x--!>z",
|
||||
"a$<!--x-->$z",
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user