~ubuntu-branches/ubuntu/utopic/golang/utopic

« back to all changes in this revision

Viewing changes to src/pkg/html/template/escape_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
551
551
                        "<textarea>&lt;a&gt;&lt;b&gt;</textarea>",
552
552
                },
553
553
                {
554
 
                        "auditable exemption from escaping",
555
 
                        "{{range .A}}{{. | noescape}}{{end}}",
556
 
                        "<a><b>",
557
 
                },
558
 
                {
559
554
                        "No tag injection",
560
555
                        `{{"10$"}}<{{"script src,evil.org/pwnd.js"}}...`,
561
556
                        `10$&lt;script src,evil.org/pwnd.js...`,
659
654
 
660
655
        for _, test := range tests {
661
656
                tmpl := New(test.name)
662
 
                // TODO: Move noescape into template/func.go
663
 
                tmpl.Funcs(FuncMap{
664
 
                        "noescape": func(a ...interface{}) string {
665
 
                                return fmt.Sprint(a...)
666
 
                        },
667
 
                })
668
657
                tmpl = Must(tmpl.Parse(test.input))
669
658
                b := new(bytes.Buffer)
670
659
                if err := tmpl.Execute(b, data); err != nil {
1539
1528
                        ".X | urlquery | html | print",
1540
1529
                        []string{"urlquery", "html"},
1541
1530
                },
 
1531
                {
 
1532
                        "{{($).X | html | print}}",
 
1533
                        "($).X | urlquery | html | print",
 
1534
                        []string{"urlquery", "html"},
 
1535
                },
1542
1536
        }
1543
1537
        for i, test := range tests {
1544
1538
                tmpl := template.Must(template.New("test").Parse(test.input))