Change HTML comment content sanitization to avoid breaking list item indent, respect table cell content rules (fixes #563).

This commit is contained in:
David Anson 2022-10-14 20:59:42 -07:00
parent 7f8962c882
commit f0bb4c639b
8 changed files with 593 additions and 63 deletions

View file

@ -57,17 +57,17 @@ test("clearHtmlCommentTextValid", (t) => {
"<!-->",
"<!--->",
"<!---->",
"<!--.........-->",
" <!--.........-->",
" <!--.........-->",
"<!--......-->",
"<!--....-->",
"<!--.-->",
"<!-- ....... -->",
" <!-- ....... -->",
" <!-- ....... -->",
"<!-- .... -->",
"<!--....-->",
"<!-- -->",
"<!-- .. -->",
"<!---->",
"<!--.....-->",
"<!--.........-->",
"<!--..-->",
"<!--. -->",
"<!--",
"-->",
"<!--",
@ -79,7 +79,7 @@ test("clearHtmlCommentTextValid", (t) => {
"-->",
"<!--",
"",
"......",
" .....",
"",
"-->",
"<!--....",
@ -93,7 +93,7 @@ test("clearHtmlCommentTextValid", (t) => {
"-->text",
"<!--....--><!--....-->",
"text<!--....-->text<!--....-->text",
"text<!--..............-->text",
"text<!--.... . .... ..-->text",
"<!--",
"text"
];
@ -118,7 +118,7 @@ test("clearHtmlCommentTextInvalid", (t) => {
"<!--->-->",
"<!--->t-->",
"<!---->t-->",
" <!-- indented code block -->"
" <!-- ........ .... ..... -->"
];
const actual = helpers.clearHtmlCommentText(invalidComments.join("\n"));
const expected = invalidComments.join("\n");
@ -134,8 +134,8 @@ test("clearHtmlCommentTextNonGreedy", (t) => {
"<!----> -->"
];
const nonGreedyResult = [
"<!--......--> -->",
"<!--......--> -->",
"<!-- .... --> -->",
"<!--..... --> -->",
"<!--.--> -->",
"<!----> -->"
];
@ -155,9 +155,9 @@ test("clearHtmlCommentTextEmbedded", (t) => {
];
const embeddedResult = [
"text<!--....-->text",
"<!--............................-->",
"<!-- .................... ..... -->",
"text<!--....-->text",
"text<!--............................-->text",
"text<!-- .................... ..... -->text",
"text<!--....-->text"
];
const actual = helpers.clearHtmlCommentText(embeddedComments.join("\n"));