diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-25 21:54:22 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-25 21:54:22 +0000 |
commit | af92e385667da3fc91ac7f9f0867a56c111110b8 (patch) | |
tree | c8e8990a2197e33f6fe50a28a16714aafe982102 /libgo/go/html | |
parent | df1304ee03f41aed179545d1e8b4684cfd22bbdf (diff) | |
download | gcc-af92e385667da3fc91ac7f9f0867a56c111110b8.tar.gz |
libgo: Update to weekly.2012-01-20.
From-SVN: r183540
Diffstat (limited to 'libgo/go/html')
-rw-r--r-- | libgo/go/html/parse.go | 4 | ||||
-rw-r--r-- | libgo/go/html/parse_test.go | 2 | ||||
-rw-r--r-- | libgo/go/html/template/doc.go | 14 | ||||
-rw-r--r-- | libgo/go/html/template/escape_test.go | 26 |
4 files changed, 23 insertions, 23 deletions
diff --git a/libgo/go/html/parse.go b/libgo/go/html/parse.go index 43c04727ab8..04f4ae75334 100644 --- a/libgo/go/html/parse.go +++ b/libgo/go/html/parse.go @@ -1713,8 +1713,8 @@ func parseForeignContent(p *parser) bool { } if breakout[p.tok.Data] { for i := len(p.oe) - 1; i >= 0; i-- { - // TODO: HTML, MathML integration points. - if p.oe[i].Namespace == "" { + // TODO: MathML integration points. + if p.oe[i].Namespace == "" || htmlIntegrationPoint(p.oe[i]) { p.oe = p.oe[:i+1] break } diff --git a/libgo/go/html/parse_test.go b/libgo/go/html/parse_test.go index c929c257727..1528dffaafa 100644 --- a/libgo/go/html/parse_test.go +++ b/libgo/go/html/parse_test.go @@ -184,7 +184,7 @@ func TestParser(t *testing.T) { {"tests4.dat", -1}, {"tests5.dat", -1}, {"tests6.dat", -1}, - {"tests10.dat", 33}, + {"tests10.dat", 35}, } for _, tf := range testFiles { f, err := os.Open("testdata/webkit/" + tf.filename) diff --git a/libgo/go/html/template/doc.go b/libgo/go/html/template/doc.go index fc0e3826442..77a9bf2e225 100644 --- a/libgo/go/html/template/doc.go +++ b/libgo/go/html/template/doc.go @@ -31,8 +31,8 @@ Example import "text/template" ... - t, err := (&template.Set{}).Parse(`{{define "T"}}Hello, {{.}}!{{end}}`) - err = t.Execute(out, "T", "<script>alert('you have been pwned')</script>") + t, err := template.New("foo").Parse(`{{define "T"}}Hello, {{.}}!{{end}}`) + err = t.ExecuteTemplate(out, "T", "<script>alert('you have been pwned')</script>") produces @@ -42,12 +42,12 @@ but with contextual autoescaping, import "html/template" ... - t, err := (&template.Set{}).Parse(`{{define "T"}}Hello, {{.}}!{{end}}`) - err = t.Execute(out, "T", "<script>alert('you have been pwned')</script>") + t, err := template.New("foo").Parse(`{{define "T"}}Hello, {{.}}!{{end}}`) + err = t.ExecuteTemplate(out, "T", "<script>alert('you have been pwned')</script>") produces safe, escaped HTML output - Hello, <script>alert('you have been pwned')</script>! + Hello, <script>alert('you have been pwned')</script>! Contexts @@ -57,8 +57,8 @@ functions to each simple action pipeline, so given the excerpt <a href="/search?q={{.}}">{{.}}</a> -At parse time each {{.}} is overwritten to add escaping functions as necessary, -in this case, +At parse time each {{.}} is overwritten to add escaping functions as necessary. +In this case it becomes <a href="/search?q={{. | urlquery}}">{{. | html}}</a> diff --git a/libgo/go/html/template/escape_test.go b/libgo/go/html/template/escape_test.go index 2ce1fb566a5..0e31674f05f 100644 --- a/libgo/go/html/template/escape_test.go +++ b/libgo/go/html/template/escape_test.go @@ -899,7 +899,7 @@ func TestErrors(t *testing.T) { }, { `<a href="{{if .F}}/foo?a={{else}}/bar/{{end}}{{.H}}">`, - "z:1: (action: [(command: [F=[H]])]) appears in an ambiguous URL context", + "z:1: {{.H}} appears in an ambiguous URL context", }, { `<a onclick="alert('Hello \`, @@ -1490,62 +1490,62 @@ func TestEnsurePipelineContains(t *testing.T) { }{ { "{{.X}}", - "[(command: [F=[X]])]", + ".X", []string{}, }, { "{{.X | html}}", - "[(command: [F=[X]]) (command: [I=html])]", + ".X | html", []string{}, }, { "{{.X}}", - "[(command: [F=[X]]) (command: [I=html])]", + ".X | html", []string{"html"}, }, { "{{.X | html}}", - "[(command: [F=[X]]) (command: [I=html]) (command: [I=urlquery])]", + ".X | html | urlquery", []string{"urlquery"}, }, { "{{.X | html | urlquery}}", - "[(command: [F=[X]]) (command: [I=html]) (command: [I=urlquery])]", + ".X | html | urlquery", []string{"urlquery"}, }, { "{{.X | html | urlquery}}", - "[(command: [F=[X]]) (command: [I=html]) (command: [I=urlquery])]", + ".X | html | urlquery", []string{"html", "urlquery"}, }, { "{{.X | html | urlquery}}", - "[(command: [F=[X]]) (command: [I=html]) (command: [I=urlquery])]", + ".X | html | urlquery", []string{"html"}, }, { "{{.X | urlquery}}", - "[(command: [F=[X]]) (command: [I=html]) (command: [I=urlquery])]", + ".X | html | urlquery", []string{"html", "urlquery"}, }, { "{{.X | html | print}}", - "[(command: [F=[X]]) (command: [I=urlquery]) (command: [I=html]) (command: [I=print])]", + ".X | urlquery | html | print", []string{"urlquery", "html"}, }, } - for _, test := range tests { + for i, test := range tests { tmpl := template.Must(template.New("test").Parse(test.input)) action, ok := (tmpl.Tree.Root.Nodes[0].(*parse.ActionNode)) if !ok { - t.Errorf("First node is not an action: %s", test.input) + t.Errorf("#%d: First node is not an action: %s", i, test.input) continue } pipe := action.Pipe ensurePipelineContains(pipe, test.ids) got := pipe.String() if got != test.output { - t.Errorf("%s, %v: want\n\t%s\ngot\n\t%s", test.input, test.ids, test.output, got) + t.Errorf("#%d: %s, %v: want\n\t%s\ngot\n\t%s", i, test.input, test.ids, test.output, got) } } } |