From: Andrew Balholm Date: Tue, 22 Nov 2011 22:26:37 +0000 (+1100) Subject: html: on EOF in a comment, ignore final dashes (up to 2) X-Git-Tag: weekly.2011-12-01~75 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=57ed39fd3bca9c69c32e55eb0a1873ab7f20bcfc;p=gostls13.git html: on EOF in a comment, ignore final dashes (up to 2) Pass tests2.dat, test 57: | | | Also pass test 58:

R=nigeltao CC=golang-dev https://golang.org/cl/5436048 --- diff --git a/src/pkg/html/parse_test.go b/src/pkg/html/parse_test.go index 3566f9f941..c1347c9dc1 100644 --- a/src/pkg/html/parse_test.go +++ b/src/pkg/html/parse_test.go @@ -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 { diff --git a/src/pkg/html/token.go b/src/pkg/html/token.go index 9400873e6b..a6fbcdfcfe 100644 --- a/src/pkg/html/token.go +++ b/src/pkg/html/token.go @@ -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 { diff --git a/src/pkg/html/token_test.go b/src/pkg/html/token_test.go index 61d4e67c06..672d60c420 100644 --- a/src/pkg/html/token_test.go +++ b/src/pkg/html/token_test.go @@ -325,6 +325,26 @@ var tokenTests = []tokenTest{ }, { "comment9", + "a", + }, + { + "comment10", + "a", + }, + { + "comment11", + "a", + }, + { + "comment12", + "a", + }, + { + "comment13", "az", "a$$z", },