From 71a9af1248e68110c5ad834602aefb39b46ba3c6 Mon Sep 17 00:00:00 2001 From: JounQin Date: Fri, 15 Dec 2023 00:02:40 +0800 Subject: [PATCH] fix: should split `DANGEROUS_OR_OBSOLETE_TAG_NAMES` --- src/index.ts | 2 +- test/__snapshots__/dompurify.spec.ts.snap | 44 ++--------------------- test/__snapshots__/fixtures.spec.ts.snap | 10 +++--- test/dompurify.spec.ts | 2 +- 4 files changed, 9 insertions(+), 49 deletions(-) diff --git a/src/index.ts b/src/index.ts index 6dcdd98b..72a3f541 100644 --- a/src/index.ts +++ b/src/index.ts @@ -79,7 +79,7 @@ const MathML_TAG_NAMES = .split(',') .map(it => `m${it}`) -const DANGEROUS_OR_OBSOLETE_TAG_NAMES = 'event-source,listing' +const DANGEROUS_OR_OBSOLETE_TAG_NAMES = 'event-source,listing'.split(',') function sanitizeNode(el: Document): Document function sanitizeNode(el: DocumentFragment): DocumentFragment diff --git a/test/__snapshots__/dompurify.spec.ts.snap b/test/__snapshots__/dompurify.spec.ts.snap index d05bc303..0968e703 100644 --- a/test/__snapshots__/dompurify.spec.ts.snap +++ b/test/__snapshots__/dompurify.spec.ts.snap @@ -8,14 +8,6 @@ exports[`dompurify compatibility > >style< > >style< 1`] = ` } `; -exports[`dompurify compatibility > 65 > 65 1`] = ` -{ - "expected": "
//["'\`-->]]>]
", - "payload": "
//["'\`-->]]>]
", - "result": "
//["'\`-->]]>]
", -} -`; - exports[`dompurify compatibility > 81 > 81 1`] = ` { "expected": "
//["'\`-->]]>]
1>//["'\`-->]]>]
", @@ -24,14 +16,6 @@ exports[`dompurify compatibility > 81 > 81 1`] = ` } `; -exports[`dompurify compatibility > 95 > 95 1`] = ` -{ - "expected": "
  • ", - "payload": "
  • ", - "result": "
    ", -} -`; - exports[`dompurify compatibility > 99 > 99 1`] = ` { "expected": "Hello @@ -61,22 +45,6 @@ exports[`dompurify compatibility > 100 > 100 1`] = ` } `; -exports[`dompurify compatibility > 111 > 111 1`] = ` -{ - "expected": "
    ", - "payload": "
    ", - "result": "
    ", -} -`; - -exports[`dompurify compatibility > 112 > 112 1`] = ` -{ - "expected": "
    //["'\`-->]]>]
    ", - "payload": "
    //["'\`-->]]>]
    ", - "result": "
    //["'\`-->]]>]
    ", -} -`; - exports[`dompurify compatibility > 121 > 121 1`] = ` { "expected": "//["'\`-->]]>] @@ -490,7 +458,7 @@ exports[`dompurify compatibility > Don't remove ARIA attributes if not prohibite { "expected": "", "payload": "", - "result": "", + "result": "", } `; @@ -567,14 +535,6 @@ exports[`dompurify compatibility > Img element inside noscript terminated inside } `; -exports[`dompurify compatibility > Img element inside shadow DOM template > Img element inside shadow DOM template 1`] = ` -{ - "expected": "", - "payload": "", - "result": "", -} -`; - exports[`dompurify compatibility > Inline SVG (data-uri) > Inline SVG (data-uri) 1`] = ` { "expected": [ @@ -889,6 +849,6 @@ exports[`dompurify compatibility > src Attributes for IMG, AUDIO, VIDEO and SOUR { "expected": "
    ", "payload": "
    ", - "result": "
    ", + "result": "
    ", } `; diff --git a/test/__snapshots__/fixtures.spec.ts.snap b/test/__snapshots__/fixtures.spec.ts.snap index 90d6a28e..3277e682 100644 --- a/test/__snapshots__/fixtures.spec.ts.snap +++ b/test/__snapshots__/fixtures.spec.ts.snap @@ -19,7 +19,7 @@ exports[`fixtures > fragment > style.html 1`] = ` exports[`fixtures > fragment > svg-g.html 1`] = ` "
    - //["'\\\`-->]]>] + //["'\\\`-->]]>]
    " `; @@ -57,14 +57,14 @@ exports[`fixtures > svg > basic.svg 1`] = ` exports[`fixtures > svg > image-href.svg 1`] = ` " - - + + 11111 - - + + " `; diff --git a/test/dompurify.spec.ts b/test/dompurify.spec.ts index b5eb0144..69608d5a 100644 --- a/test/dompurify.spec.ts +++ b/test/dompurify.spec.ts @@ -43,6 +43,6 @@ describe('dompurify compatibility', () => { } test('mismatches', () => { - expect(mismatches).toMatchInlineSnapshot(`72`) + expect(mismatches).toMatchInlineSnapshot(`67`) }) })