From: Roland Shoemaker Date: Thu, 3 Aug 2023 19:24:13 +0000 (-0700) Subject: [release-branch.go1.21] html/template: support HTML-like comments in script contexts X-Git-Tag: go1.21.1~2 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b0e1d3ea26e8e8fce7726690c9ef0597e60739fb;p=gostls13.git [release-branch.go1.21] html/template: support HTML-like comments in script contexts Per Appendix B.1.1 of the ECMAScript specification, support HTML-like comments in script contexts. Also per section 12.5, support hashbang comments. This brings our parsing in-line with how browsers treat these comment types. Thanks to Takeshi Kaneko (GMO Cybersecurity by Ierae, Inc.) for reporting this issue. Fixes #62196 Fixes #62396 Fixes CVE-2023-39318 Change-Id: Id512702c5de3ae46cf648e268cb10e1eb392a181 Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1976593 Run-TryBot: Roland Shoemaker Reviewed-by: Tatiana Bradley Reviewed-by: Damien Neil Reviewed-by: Dmitri Shuralyov Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/2014618 Reviewed-on: https://go-review.googlesource.com/c/go/+/526096 TryBot-Result: Gopher Robot Run-TryBot: Cherry Mui --- diff --git a/src/html/template/context.go b/src/html/template/context.go index c28fb0c5ea..e07a0c4a02 100644 --- a/src/html/template/context.go +++ b/src/html/template/context.go @@ -128,6 +128,10 @@ const ( stateJSBlockCmt // stateJSLineCmt occurs inside a JavaScript // line comment. stateJSLineCmt + // stateJSHTMLOpenCmt occurs inside a JavaScript HTML-like comment. + stateJSHTMLCloseCmt // stateCSS occurs inside a