From 7673a52a02930909edb4f4328c568981642bb791 Mon Sep 17 00:00:00 2001 From: abdo Date: Tue, 9 Mar 2021 03:15:08 +0300 Subject: [PATCH] Strip HTML comments from external pastes Fix a regression caused by https://github.com/ankitects/anki/commit/150de7a683348198183166ddda5791eb5ff6bc28 --- ts/editor/htmlFilter.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ts/editor/htmlFilter.ts b/ts/editor/htmlFilter.ts index 39a2cad9e..d9fc260f6 100644 --- a/ts/editor/htmlFilter.ts +++ b/ts/editor/htmlFilter.ts @@ -132,13 +132,17 @@ let filterInternalNode = function (elem: Element) { // filtering from external sources let filterNode = function (node: Node, extendedMode: boolean): void { + if (node.nodeType === Node.COMMENT_NODE) { + node.parentNode.removeChild(node); + return; + } if (!nodeIsElement(node)) { return; } // descend first, and take a copy of the child nodes as the loop will skip // elements due to node modifications otherwise - for (const child of [...node.children]) { + for (const child of [...node.childNodes]) { filterNode(child, extendedMode); }