// SPDX-License-Identifier: AGPL-3.0-or-later
package markdown
import (
"context"
"strings"
"testing"
)
// TestRender_HostileInputs is the XSS-vector cheatsheet. Every
// fixture is a markdown body that *attempts* to inject executable
// JS through a different vector. The pass condition: the rendered
// HTML contains no ``,
``,
``,
// Inline event handlers.
``,
``,
`x`,
`
`,
// Style with expressions.
``,
`
x
`,
// javascript: links.
`[click](javascript:alert(1))`,
`x`,
`x`,
`[click](JAVASCRIPT:alert(1))`,
// data: URIs (we disallow even data:image).
``,
`[x](data:text/html,)`,
// vbscript:.
`x`,
// SVG-embedded scripts.
``,
``,
// iframes.
``,
``,
// HTML in markdown link text doesn't escape sanitizer.
`[](https://example.com)`,
// Mutation XSS via mismatched quotes.
`x`,
// Encoded payloads.
`x`,
`x`,
// Backticked code-like content shouldn't escape.
"``",
// Embedded in autolinks.
``,
// Object/embed.
``,
`