Skip to content

Commit

Permalink
html: avoid endless loop on error token
Browse files Browse the repository at this point in the history
Fixes #70179

Change-Id: I2a0a1fc2e96f7d8eefd0abdf7ef8ba243a6e8645
GitHub-Last-Rev: a601ecd
GitHub-Pull-Request: #226
Reviewed-on: https://go-review.googlesource.com/c/net/+/624895
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
yincongcyincong authored and gopherbot committed Dec 18, 2024
1 parent 9af49ef commit b935f7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions html/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,10 @@ func afterHeadIM(p *parser) bool {

p.parseImpliedToken(StartTagToken, a.Body, a.Body.String())
p.framesetOK = true
if p.tok.Type == ErrorToken {
// Stop parsing.
return true
}
return false
}

Expand Down
1 change: 1 addition & 0 deletions html/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ func TestParseFragmentForeignContentTemplates(t *testing.T) {
srcs := []string{
"<math><html><template><mn><template></template></template>",
"<math><math><head><mi><template>",
"<svg><head><title><select><input>",
}
for _, src := range srcs {
// The next line shouldn't infinite-loop.
Expand Down

0 comments on commit b935f7b

Please sign in to comment.