]> Cypherpunks repositories - gostls13.git/commit
html: rewrite the tokenizer to be more consistent.
authorNigel Tao <nigeltao@golang.org>
Thu, 13 Oct 2011 22:58:39 +0000 (09:58 +1100)
committerNigel Tao <nigeltao@golang.org>
Thu, 13 Oct 2011 22:58:39 +0000 (09:58 +1100)
commita49b8b9875fd43774e96ed81ce1316c32fb48fa0
tree6e83491beccf66ba3c00c678813db64ed3ccb100
parent6198336bb51c5a176adce5777159509954b211ac
html: rewrite the tokenizer to be more consistent.

Previously, the tokenizer made two passes per token. The first pass
established the token boundary. The second pass picked out the tag name
and attributes inside that boundary. This was problematic when the two
passes disagreed. For example, "<p id=can't><p id=won't>" caused an
infinite loop because the first pass skipped everything inside the
single quotes, and recognized only one token, but the second pass never
got past the first '>'.

This change rewrites the tokenizer to use one pass, accumulating the
boundary points of token text, tag names, attribute keys and attribute
values as it looks for the token endpoint.

It should still be reasonably efficient: text, names, keys and values
are not lower-cased or unescaped (and converted from []byte to string)
until asked for.

One of the token_test test cases was fixed to be consistent with
html5lib. Three more test cases were temporarily disabled, and will be
re-enabled in a follow-up CL. All the parse_test test cases pass.

R=andybalholm, gri
CC=golang-dev
https://golang.org/cl/5244061
src/pkg/html/escape.go
src/pkg/html/token.go
src/pkg/html/token_test.go