html/template: set division context when a template literal closes - #81190
Open
harjothkhara wants to merge 1 commit into
Open
html/template: set division context when a template literal closes#81190harjothkhara wants to merge 1 commit into
harjothkhara wants to merge 1 commit into
Conversation
A '/' that follows a JavaScript template literal starts a division,
not a regexp literal, but tJSTmpl left jsCtx unchanged when it saw
the closing backtick. The context stayed jsCtxRegexp from when the
literal opened, so a template action after the literal was escaped
as regexp text and its value was written without quotes:
<script>let x = `a`/{{.}}/b;</script>
executed with the value "alert`1`" produced
<script>let x = `a`/alert`1`/b;</script>
Set jsCtx to jsCtxDivOp when the closing backtick is reached, the
same way tJSDelimited does when a JS string or regexp closes.
Fixes golang#81117
harjothkhara
marked this pull request as ready for review
August 28, 2026 05:47
Contributor
|
This PR (HEAD: a341fec) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/823564. Important tips:
|
Contributor
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/823564. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A '/' that follows a JavaScript template literal starts a division,
<script>let x = `a`/{{.}}/b;</script>not a regexp literal, but tJSTmpl left jsCtx unchanged when it saw
the closing backtick. The context stayed jsCtxRegexp from when the
literal opened, so a template action after the literal was escaped
as regexp text and its value was written without quotes:
executed with the value "alert
<script>let x = `a`/alert`1`/b;</script>1" producedSet jsCtx to jsCtxDivOp when the closing backtick is reached, the
same way tJSDelimited does when a JS string or regexp closes.
Fixes #81117