internal/web: stop double-escaping of code in non-playground examples
CL 317655 introduced an issue causing non-playground code examples
to be double-escaped, causing HTML escape sequences and elements
to appear in the code, such as the examples in crypto/rsa,
as reported in golang/go#46839. This change treats the code as
template.HTML rather than string after running through (*Page).Node
(which formats the code as HTML) and doing some basic transformations,
preventing this double-escaping from occurring.
Fixes golang/go#46839
Change-Id: Id226147eb51219bd5e2db61e959519258e39a298
GitHub-Last-Rev: 81f8dc5e87
GitHub-Pull-Request: golang/website#73
Reviewed-on: https://go-review.googlesource.com/c/website/+/332889
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
This commit is contained in:
Родитель
183dc663dd
Коммит
7b37f32c8b
|
@ -191,3 +191,9 @@ GET https://golang.org/x/net
|
|||
code == 200
|
||||
body contains <meta name="go-import" content="golang.org/x/net git https://go.googlesource.com/net">
|
||||
body !contains UA-
|
||||
|
||||
GET https://golang.org/pkg/crypto/rsa/?m=old
|
||||
body contains []byte("orders")
|
||||
body !contains []byte(&#34;orders&#34;)
|
||||
body contains <span class="comment">
|
||||
body !contains <span class="comment">
|
||||
|
|
|
@ -74,9 +74,10 @@ func (p *Page) Example(funcName string) template.HTML {
|
|||
|
||||
newPage := *p
|
||||
newPage.Data = struct {
|
||||
Name, Doc, Code, Play, Output string
|
||||
Name, Doc, Play, Output string
|
||||
Code template.HTML
|
||||
}{
|
||||
eg.Name, eg.Doc, code, play, out,
|
||||
eg.Name, eg.Doc, play, out, template.HTML(code),
|
||||
}
|
||||
err := t.Execute(&buf, &newPage)
|
||||
if err != nil {
|
||||
|
|
Загрузка…
Ссылка в новой задаче