]> Cypherpunks repositories - gostls13.git/commit
html/template,text/template: switch to Unicode escapes for JSON compatibility
authorempijei <robclap8@gmail.com>
Fri, 27 Mar 2020 18:27:55 +0000 (19:27 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Thu, 16 Apr 2020 17:13:33 +0000 (17:13 +0000)
commitd4d298040d072ddacea0e0d6b55fb148fff18070
treeb36c1068e498b09f0e1b320c2784ba14ddf4ec8b
parent71a671839f95fb43091316c72cae87c049c81bce
html/template,text/template: switch to Unicode escapes for JSON compatibility

The existing implementation is not compatible with JSON
escape as it uses hex escaping.
Unicode escape, instead, is valid for both JSON and JS.
This fix avoids creating a separate escaping context for
scripts of type "application/ld+json" and it is more
future-proof in case more JSON+JS contexts get added
to the platform (e.g. import maps).

Fixes #33671
Fixes #37634

Change-Id: Id6f6524b4abc52e81d9d744d46bbe5bf2e081543
Reviewed-on: https://go-review.googlesource.com/c/go/+/226097
Reviewed-by: Carl Johnson <me@carlmjohnson.net>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/html/template/content_test.go
src/html/template/escape_test.go
src/html/template/example_test.go
src/html/template/js.go
src/html/template/js_test.go
src/html/template/template_test.go
src/text/template/exec_test.go
src/text/template/funcs.go