Explorar el Código

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: 4a9da031771882a2798ceae57d4f8a983d4dcbf9
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>
Dario hace 6 años
padre
commit
2ec189313e
Se han modificado 2 ficheros con 6 adiciones y 0 borrados
  1. 1 0
      html/token.go
  2. 5 0
      html/token_test.go

+ 1 - 0
html/token.go

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

+ 5 - 0
html/token_test.go

@@ -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",