html: fix tokenizer error

Trailing '<' entities in the text token make the tokenizer fail
for escapable raw text elements like title and textarea

Fixes golang/go#34281

Change-Id: I6fe8f2229b5fd639cf5a02ab1db31f18ea034c8b
GitHub-Last-Rev: 4a9da03177
GitHub-Pull-Request: golang/net#53
Reviewed-on: https://go-review.googlesource.com/c/net/+/196620
Run-TryBot: Kunpei Sakai <kunpei@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
This commit is contained in:
Dario
2019-09-24 14:36:10 +00:00
committed by Nigel Tao
parent 2e5a9a9514
commit 2ec189313e
2 changed files with 6 additions and 0 deletions

View File

@@ -347,6 +347,7 @@ loop:
break loop
}
if c != '/' {
z.raw.end--
continue loop
}
if z.readRawEndTag() || z.err != nil {

View File

@@ -258,6 +258,11 @@ var tokenTests = []tokenTest{
"<title><b>K&amp;R C</b></title>",
"<title>$&lt;b&gt;K&amp;R C&lt;/b&gt;$</title>",
},
{
"title with trailing '&lt;' entity",
"<title>foobar<</title>",
"<title>$foobar&lt;$</title>",
},
// DOCTYPE tests.
{
"Proper DOCTYPE",