From: Mike Samuel Date: Mon, 12 Sep 2011 23:01:30 +0000 (-0700) Subject: exp/template/html: fix bug /*/ is not a full JS block comment. X-Git-Tag: weekly.2011-09-16~51 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=80a5ddbdb1af3442e86b7db2fbb5f25e3bdca9fe;p=gostls13.git 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 --- 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) { `