From 80a5ddbdb1af3442e86b7db2fbb5f25e3bdca9fe Mon Sep 17 00:00:00 2001 From: Mike Samuel Date: Mon, 12 Sep 2011 16:01:30 -0700 Subject: [PATCH] exp/template/html: fix bug /*/ is not a full JS block comment. Similar tests for CSS already catch this problem in tCSS. R=nigeltao CC=golang-dev https://golang.org/cl/4967065 --- src/pkg/exp/template/html/escape.go | 4 ++-- src/pkg/exp/template/html/escape_test.go | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pkg/exp/template/html/escape.go b/src/pkg/exp/template/html/escape.go index d3c06bb7f6..955b41be22 100644 --- a/src/pkg/exp/template/html/escape.go +++ b/src/pkg/exp/template/html/escape.go @@ -487,9 +487,9 @@ func tJS(c context, s []byte) (context, []byte) { case '/': switch { case i+1 < len(s) && s[i+1] == '/': - c.state = stateJSLineCmt + c.state, i = stateJSLineCmt, i+1 case i+1 < len(s) && s[i+1] == '*': - c.state = stateJSBlockCmt + c.state, i = stateJSBlockCmt, i+1 case c.jsCtx == jsCtxRegexp: c.state = stateJSRegexp default: diff --git a/src/pkg/exp/template/html/escape_test.go b/src/pkg/exp/template/html/escape_test.go index 23f5734987..488f33a4ad 100644 --- a/src/pkg/exp/template/html/escape_test.go +++ b/src/pkg/exp/template/html/escape_test.go @@ -643,6 +643,14 @@ func TestEscapeText(t *testing.T) { `