MCPcopy Create free account
hub / github.com/commonmark/cmark / test_safe

Function test_safe

api_test/main.c:898–911  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

896}
897
898static void test_safe(test_batch_runner *runner) {
899 // Test safe mode
900 static const char raw_html[] = "<div>\nhi\n</div>\n\n<a>hi</"
901 "a>\n[link](JAVAscript:alert('hi'))\n![image]("
902 "file:my.js)\n";
903 char *html = cmark_markdown_to_html(raw_html, sizeof(raw_html) - 1,
904 CMARK_OPT_DEFAULT);
905 STR_EQ(runner, html, "<!-- raw HTML omitted -->\n<p><!-- raw HTML omitted "
906 "-->hi<!-- raw HTML omitted -->\n<a "
907 "href=\"\">link</a>\n<img src=\"\" alt=\"image\" "
908 "/></p>\n",
909 "input with raw HTML and dangerous links");
910 free(html);
911}
912
913static void test_md_to_html(test_batch_runner *runner, const char *markdown,
914 const char *expected_html, const char *msg) {

Callers 1

mainFunction · 0.85

Calls 2

cmark_markdown_to_htmlFunction · 0.85
STR_EQFunction · 0.85

Tested by

no test coverage detected