Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(25)

Delta Between Two Patch Sets: src/pkg/html/template/escape_test.go

Issue 12708044: code review 12708044: encoding/json: escape & always (Closed)
Left Patch Set: Created 11 years, 7 months ago
Right Patch Set: diff -r 690c179cc3fd https://code.google.com/p/go/ Created 11 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/html/template/content_test.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package template 5 package template
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "encoding/json" 9 "encoding/json"
10 "fmt" 10 "fmt"
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 `&iexcl;<b class="foo">Hello</b>, <textarea>O'World</tex tarea>!`, 531 `&iexcl;<b class="foo">Hello</b>, <textarea>O'World</tex tarea>!`,
532 }, 532 },
533 { 533 {
534 "typed HTML in attribute", 534 "typed HTML in attribute",
535 `<div title="{{.W}}">`, 535 `<div title="{{.W}}">`,
536 `<div title="&iexcl;Hello, O&#39;World!">`, 536 `<div title="&iexcl;Hello, O&#39;World!">`,
537 }, 537 },
538 { 538 {
539 "typed HTML in script", 539 "typed HTML in script",
540 `<button onclick="alert({{.W}})">`, 540 `<button onclick="alert({{.W}})">`,
541 » » » `<button onclick="alert(&#34;&amp;iexcl;\u003cb class=\& #34;foo\&#34;\u003eHello\u003c/b\u003e, \u003ctextarea\u003eO&#39;World\u003c/te xtarea\u003e!&#34;)">`, 541 » » » `<button onclick="alert(&#34;\u0026iexcl;\u003cb class=\ &#34;foo\&#34;\u003eHello\u003c/b\u003e, \u003ctextarea\u003eO&#39;World\u003c/t extarea\u003e!&#34;)">`,
542 }, 542 },
543 { 543 {
544 "typed HTML in RCDATA", 544 "typed HTML in RCDATA",
545 `<textarea>{{.W}}</textarea>`, 545 `<textarea>{{.W}}</textarea>`,
546 `<textarea>&iexcl;&lt;b class=&#34;foo&#34;&gt;Hello&lt; /b&gt;, &lt;textarea&gt;O&#39;World&lt;/textarea&gt;!</textarea>`, 546 `<textarea>&iexcl;&lt;b class=&#34;foo&#34;&gt;Hello&lt; /b&gt;, &lt;textarea&gt;O&#39;World&lt;/textarea&gt;!</textarea>`,
547 }, 547 },
548 { 548 {
549 "range in textarea", 549 "range in textarea",
550 "<textarea>{{range .A}}{{.}}{{end}}</textarea>", 550 "<textarea>{{range .A}}{{.}}{{end}}</textarea>",
551 "<textarea>&lt;a&gt;&lt;b&gt;</textarea>", 551 "<textarea>&lt;a&gt;&lt;b&gt;</textarea>",
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 1642
1643 func BenchmarkEscapedExecute(b *testing.B) { 1643 func BenchmarkEscapedExecute(b *testing.B) {
1644 tmpl := Must(New("t").Parse(`<a onclick="alert('{{.}}')">{{.}}</a>`)) 1644 tmpl := Must(New("t").Parse(`<a onclick="alert('{{.}}')">{{.}}</a>`))
1645 var buf bytes.Buffer 1645 var buf bytes.Buffer
1646 b.ResetTimer() 1646 b.ResetTimer()
1647 for i := 0; i < b.N; i++ { 1647 for i := 0; i < b.N; i++ {
1648 tmpl.Execute(&buf, "foo & 'bar' & baz") 1648 tmpl.Execute(&buf, "foo & 'bar' & baz")
1649 buf.Reset() 1649 buf.Reset()
1650 } 1650 }
1651 } 1651 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b