From 2ec189313ef0a07735684caebd1ba8b8ebca456f Mon Sep 17 00:00:00 2001 From: Dario Date: Tue, 24 Sep 2019 14:36:10 +0000 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Nigel Tao --- html/token.go | 1 + html/token_test.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/html/token.go b/html/token.go index b426ae07..ae0d1b05 100644 --- a/html/token.go +++ b/html/token.go @@ -347,6 +347,7 @@ loop: break loop } if c != '/' { + z.raw.end-- continue loop } if z.readRawEndTag() || z.err != nil { diff --git a/html/token_test.go b/html/token_test.go index f2473ba6..d59c3c63 100644 --- a/html/token_test.go +++ b/html/token_test.go @@ -258,6 +258,11 @@ var tokenTests = []tokenTest{ "<b>K&R C</b>", "$<b>K&R C</b>$", }, + { + "title with trailing '<' entity", + "foobar<", + "$foobar<$", + }, // DOCTYPE tests. { "Proper DOCTYPE",