Skip to content

html/template: comment handling introduced in 1.21.1 breaks valid scripts #63183

@jupenur

Description

@jupenur

What version of Go are you using (go version)?

1.21.1

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Playground

What did you do?

Run this code on the playground:

package main

import (
	"html/template"
	"os"
)

func main() {
	t, _ := template.New("T").Parse(`
		<script>
			if (a-->b) {
				// do stuff
			}
		</script>
	`)
	t.ExecuteTemplate(os.Stdout, "T", "")
}

What did you expect to see?

		<script>
			if (a-->b) {
				
			}
		</script>

What did you see instead?

		<script>
			if (a
				
			}
		</script>

Metadata

Metadata

Labels

NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Security

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions