mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-31 22:41:53 +02:00
@@ -21,7 +21,7 @@ func TestTypedContent(t *testing.T) {
|
||||
htmltemplate.HTML(`Hello, <b>World</b> &tc!`),
|
||||
htmltemplate.HTMLAttr(` dir="ltr"`),
|
||||
htmltemplate.JS(`c && alert("Hello, World!");`),
|
||||
htmltemplate.JSStr(`Hello, World & O'Reilly\x21`),
|
||||
htmltemplate.JSStr(`Hello, World & O'Reilly\u0021`),
|
||||
htmltemplate.URL(`greeting=H%69,&addressee=(World)`),
|
||||
htmltemplate.Srcset(`greeting=H%69,&addressee=(World) 2x, https://golang.org/favicon.ico 500.5w`),
|
||||
htmltemplate.URL(`,foo/,`),
|
||||
@@ -73,7 +73,7 @@ func TestTypedContent(t *testing.T) {
|
||||
`Hello, <b>World</b> &tc!`,
|
||||
` dir="ltr"`,
|
||||
`c && alert("Hello, World!");`,
|
||||
`Hello, World & O'Reilly\x21`,
|
||||
`Hello, World & O'Reilly\u0021`,
|
||||
`greeting=H%69,&addressee=(World)`,
|
||||
`greeting=H%69,&addressee=(World) 2x, https://golang.org/favicon.ico 500.5w`,
|
||||
`,foo/,`,
|
||||
@@ -103,7 +103,7 @@ func TestTypedContent(t *testing.T) {
|
||||
`Hello, World &tc!`,
|
||||
` dir="ltr"`,
|
||||
`c && alert("Hello, World!");`,
|
||||
`Hello, World & O'Reilly\x21`,
|
||||
`Hello, World & O'Reilly\u0021`,
|
||||
`greeting=H%69,&addressee=(World)`,
|
||||
`greeting=H%69,&addressee=(World) 2x, https://golang.org/favicon.ico 500.5w`,
|
||||
`,foo/,`,
|
||||
@@ -118,7 +118,7 @@ func TestTypedContent(t *testing.T) {
|
||||
`Hello, World &tc!`,
|
||||
` dir="ltr"`,
|
||||
`c && alert("Hello, World!");`,
|
||||
`Hello, World & O'Reilly\x21`,
|
||||
`Hello, World & O'Reilly\u0021`,
|
||||
`greeting=H%69,&addressee=(World)`,
|
||||
`greeting=H%69,&addressee=(World) 2x, https://golang.org/favicon.ico 500.5w`,
|
||||
`,foo/,`,
|
||||
@@ -133,7 +133,7 @@ func TestTypedContent(t *testing.T) {
|
||||
`Hello, <b>World</b> &tc!`,
|
||||
` dir="ltr"`,
|
||||
`c && alert("Hello, World!");`,
|
||||
`Hello, World & O'Reilly\x21`,
|
||||
`Hello, World & O'Reilly\u0021`,
|
||||
`greeting=H%69,&addressee=(World)`,
|
||||
`greeting=H%69,&addressee=(World) 2x, https://golang.org/favicon.ico 500.5w`,
|
||||
`,foo/,`,
|
||||
@@ -149,7 +149,7 @@ func TestTypedContent(t *testing.T) {
|
||||
// Not escaped.
|
||||
`c && alert("Hello, World!");`,
|
||||
// Escape sequence not over-escaped.
|
||||
`"Hello, World & O'Reilly\x21"`,
|
||||
`"Hello, World & O'Reilly\u0021"`,
|
||||
`"greeting=H%69,\u0026addressee=(World)"`,
|
||||
`"greeting=H%69,\u0026addressee=(World) 2x, https://golang.org/favicon.ico 500.5w"`,
|
||||
`",foo/,"`,
|
||||
@@ -165,7 +165,7 @@ func TestTypedContent(t *testing.T) {
|
||||
// Not JS escaped but HTML escaped.
|
||||
`c && alert("Hello, World!");`,
|
||||
// Escape sequence not over-escaped.
|
||||
`"Hello, World & O'Reilly\x21"`,
|
||||
`"Hello, World & O'Reilly\u0021"`,
|
||||
`"greeting=H%69,\u0026addressee=(World)"`,
|
||||
`"greeting=H%69,\u0026addressee=(World) 2x, https://golang.org/favicon.ico 500.5w"`,
|
||||
`",foo/,"`,
|
||||
@@ -174,30 +174,30 @@ func TestTypedContent(t *testing.T) {
|
||||
{
|
||||
`<script>alert("{{.}}")</script>`,
|
||||
[]string{
|
||||
`\x3cb\x3e \x22foo%\x22 O\x27Reilly \x26bar;`,
|
||||
`a[href =~ \x22\/\/example.com\x22]#foo`,
|
||||
`Hello, \x3cb\x3eWorld\x3c\/b\x3e \x26amp;tc!`,
|
||||
` dir=\x22ltr\x22`,
|
||||
`c \x26\x26 alert(\x22Hello, World!\x22);`,
|
||||
`\u003cb\u003e \u0022foo%\u0022 O\u0027Reilly \u0026bar;`,
|
||||
`a[href =~ \u0022\/\/example.com\u0022]#foo`,
|
||||
`Hello, \u003cb\u003eWorld\u003c\/b\u003e \u0026amp;tc!`,
|
||||
` dir=\u0022ltr\u0022`,
|
||||
`c \u0026\u0026 alert(\u0022Hello, World!\u0022);`,
|
||||
// Escape sequence not over-escaped.
|
||||
`Hello, World \x26 O\x27Reilly\x21`,
|
||||
`greeting=H%69,\x26addressee=(World)`,
|
||||
`greeting=H%69,\x26addressee=(World) 2x, https:\/\/golang.org\/favicon.ico 500.5w`,
|
||||
`Hello, World \u0026 O\u0027Reilly\u0021`,
|
||||
`greeting=H%69,\u0026addressee=(World)`,
|
||||
`greeting=H%69,\u0026addressee=(World) 2x, https:\/\/golang.org\/favicon.ico 500.5w`,
|
||||
`,foo\/,`,
|
||||
},
|
||||
},
|
||||
{
|
||||
`<script type="text/javascript">alert("{{.}}")</script>`,
|
||||
[]string{
|
||||
`\x3cb\x3e \x22foo%\x22 O\x27Reilly \x26bar;`,
|
||||
`a[href =~ \x22\/\/example.com\x22]#foo`,
|
||||
`Hello, \x3cb\x3eWorld\x3c\/b\x3e \x26amp;tc!`,
|
||||
` dir=\x22ltr\x22`,
|
||||
`c \x26\x26 alert(\x22Hello, World!\x22);`,
|
||||
`\u003cb\u003e \u0022foo%\u0022 O\u0027Reilly \u0026bar;`,
|
||||
`a[href =~ \u0022\/\/example.com\u0022]#foo`,
|
||||
`Hello, \u003cb\u003eWorld\u003c\/b\u003e \u0026amp;tc!`,
|
||||
` dir=\u0022ltr\u0022`,
|
||||
`c \u0026\u0026 alert(\u0022Hello, World!\u0022);`,
|
||||
// Escape sequence not over-escaped.
|
||||
`Hello, World \x26 O\x27Reilly\x21`,
|
||||
`greeting=H%69,\x26addressee=(World)`,
|
||||
`greeting=H%69,\x26addressee=(World) 2x, https:\/\/golang.org\/favicon.ico 500.5w`,
|
||||
`Hello, World \u0026 O\u0027Reilly\u0021`,
|
||||
`greeting=H%69,\u0026addressee=(World)`,
|
||||
`greeting=H%69,\u0026addressee=(World) 2x, https:\/\/golang.org\/favicon.ico 500.5w`,
|
||||
`,foo\/,`,
|
||||
},
|
||||
},
|
||||
@@ -211,7 +211,7 @@ func TestTypedContent(t *testing.T) {
|
||||
// Not escaped.
|
||||
`c && alert("Hello, World!");`,
|
||||
// Escape sequence not over-escaped.
|
||||
`"Hello, World & O'Reilly\x21"`,
|
||||
`"Hello, World & O'Reilly\u0021"`,
|
||||
`"greeting=H%69,\u0026addressee=(World)"`,
|
||||
`"greeting=H%69,\u0026addressee=(World) 2x, https://golang.org/favicon.ico 500.5w"`,
|
||||
`",foo/,"`,
|
||||
@@ -227,7 +227,7 @@ func TestTypedContent(t *testing.T) {
|
||||
`Hello, <b>World</b> &tc!`,
|
||||
` dir="ltr"`,
|
||||
`c && alert("Hello, World!");`,
|
||||
`Hello, World & O'Reilly\x21`,
|
||||
`Hello, World & O'Reilly\u0021`,
|
||||
`greeting=H%69,&addressee=(World)`,
|
||||
`greeting=H%69,&addressee=(World) 2x, https://golang.org/favicon.ico 500.5w`,
|
||||
`,foo/,`,
|
||||
@@ -236,15 +236,15 @@ func TestTypedContent(t *testing.T) {
|
||||
{
|
||||
`<button onclick='alert("{{.}}")'>`,
|
||||
[]string{
|
||||
`\x3cb\x3e \x22foo%\x22 O\x27Reilly \x26bar;`,
|
||||
`a[href =~ \x22\/\/example.com\x22]#foo`,
|
||||
`Hello, \x3cb\x3eWorld\x3c\/b\x3e \x26amp;tc!`,
|
||||
` dir=\x22ltr\x22`,
|
||||
`c \x26\x26 alert(\x22Hello, World!\x22);`,
|
||||
`\u003cb\u003e \u0022foo%\u0022 O\u0027Reilly \u0026bar;`,
|
||||
`a[href =~ \u0022\/\/example.com\u0022]#foo`,
|
||||
`Hello, \u003cb\u003eWorld\u003c\/b\u003e \u0026amp;tc!`,
|
||||
` dir=\u0022ltr\u0022`,
|
||||
`c \u0026\u0026 alert(\u0022Hello, World!\u0022);`,
|
||||
// Escape sequence not over-escaped.
|
||||
`Hello, World \x26 O\x27Reilly\x21`,
|
||||
`greeting=H%69,\x26addressee=(World)`,
|
||||
`greeting=H%69,\x26addressee=(World) 2x, https:\/\/golang.org\/favicon.ico 500.5w`,
|
||||
`Hello, World \u0026 O\u0027Reilly\u0021`,
|
||||
`greeting=H%69,\u0026addressee=(World)`,
|
||||
`greeting=H%69,\u0026addressee=(World) 2x, https:\/\/golang.org\/favicon.ico 500.5w`,
|
||||
`,foo\/,`,
|
||||
},
|
||||
},
|
||||
@@ -256,7 +256,7 @@ func TestTypedContent(t *testing.T) {
|
||||
`Hello%2c%20%3cb%3eWorld%3c%2fb%3e%20%26amp%3btc%21`,
|
||||
`%20dir%3d%22ltr%22`,
|
||||
`c%20%26%26%20alert%28%22Hello%2c%20World%21%22%29%3b`,
|
||||
`Hello%2c%20World%20%26%20O%27Reilly%5cx21`,
|
||||
`Hello%2c%20World%20%26%20O%27Reilly%5cu0021`,
|
||||
// Quotes and parens are escaped but %69 is not over-escaped. HTML escaping is done.
|
||||
`greeting=H%69,&addressee=%28World%29`,
|
||||
`greeting%3dH%2569%2c%26addressee%3d%28World%29%202x%2c%20https%3a%2f%2fgolang.org%2ffavicon.ico%20500.5w`,
|
||||
@@ -271,7 +271,7 @@ func TestTypedContent(t *testing.T) {
|
||||
`Hello%2c%20%3cb%3eWorld%3c%2fb%3e%20%26amp%3btc%21`,
|
||||
`%20dir%3d%22ltr%22`,
|
||||
`c%20%26%26%20alert%28%22Hello%2c%20World%21%22%29%3b`,
|
||||
`Hello%2c%20World%20%26%20O%27Reilly%5cx21`,
|
||||
`Hello%2c%20World%20%26%20O%27Reilly%5cu0021`,
|
||||
// Quotes and parens are escaped but %69 is not over-escaped. HTML escaping is not done.
|
||||
`greeting=H%69,&addressee=%28World%29`,
|
||||
`greeting%3dH%2569%2c%26addressee%3d%28World%29%202x%2c%20https%3a%2f%2fgolang.org%2ffavicon.ico%20500.5w`,
|
||||
|
Reference in New Issue
Block a user