`,
+ },
+ {
+ "styleURLNotEncodedForHTMLInCdata",
+ ``,
+ ``,
+ },
{
"styleURLMixedCase",
``,
@@ -324,13 +339,19 @@ func TestEscape(t *testing.T) {
``,
``,
},
+ {
+ "comment",
+ "Hello, {{.C}}",
+ // TODO: Elide comment.
+ "Hello, <Cincinatti>",
+ },
}
for _, test := range tests {
tmpl := template.Must(template.New(test.name).Parse(test.input))
- tmpl, err := Escape(tmpl)
+ tmpl = template.Must(Escape(tmpl))
b := new(bytes.Buffer)
- if err = tmpl.Execute(b, data); err != nil {
+ if err := tmpl.Execute(b, data); err != nil {
t.Errorf("%s: template execution failed: %s", test.name, err)
continue
}
@@ -410,6 +431,10 @@ func TestErrors(t *testing.T) {
"foo();",
+ "z ends in a non-text context: {stateJS",
+ },
{
``,
"z:1: (action: [(command: [F=[H]])]) appears in an ambiguous URL context",
@@ -446,6 +471,10 @@ func TestErrors(t *testing.T) {
``,
`z:1: (action: [(command: [F=[X]])]) appears inside a comment`,
},
+ {
+ "",
+ "z:1: (action: [(command: [F=[H]])]) appears inside a comment",
+ },
}
for _, test := range tests {
@@ -765,6 +794,94 @@ func TestEscapeText(t *testing.T) {
`foo`,
+ context{state: stateJS, jsCtx: jsCtxDivOp, element: elementScript},
+ },
+ {
+ ``,
+ context{state: stateText},
+ },
+ {
+ `