From fc07c113cd44933a3b01f586172edd60c0f7774f Mon Sep 17 00:00:00 2001 From: "J. King" Date: Sun, 26 Mar 2023 16:15:35 -0400 Subject: [PATCH] Add namespace-related tests --- tests/cases/std-sanitize.json | 530 ++++++++++++++++++++++++++++++++++ tests/parsetests | 78 ++++- 2 files changed, 606 insertions(+), 2 deletions(-) diff --git a/tests/cases/std-sanitize.json b/tests/cases/std-sanitize.json index c083491..17d8ab7 100644 --- a/tests/cases/std-sanitize.json +++ b/tests/cases/std-sanitize.json @@ -5,6 +5,7 @@ "inputType": "literal", "output": null, "exceptionType": "TypeError", + "negativeTest": false, "message": "Sanitizer.sanitize() should throw an error." }, { @@ -15,6 +16,7 @@ "inputType": "literal", "output": null, "exceptionType": "TypeError", + "negativeTest": false, "message": "Sanitizer.sanitize(null)." }, { @@ -24,6 +26,7 @@ ], "inputType": "document-fragment", "output": "hello", + "negativeTest": false, "message": "Sanitizer.sanitze(DocumentFragment)" }, { @@ -33,6 +36,7 @@ ], "inputType": "document", "output": "hello", + "negativeTest": false, "message": "Sanitizer.sanitze(Document)" }, { @@ -42,6 +46,7 @@ ], "inputType": "document", "output": "test", + "negativeTest": false, "message": "SanitizerAPI with config: string, sanitize from document function for " }, { @@ -51,6 +56,7 @@ ], "inputType": "document", "output": "bla", + "negativeTest": false, "message": "SanitizerAPI with config: html fragment, sanitize from document function for " }, { @@ -60,6 +66,7 @@ ], "inputType": "document", "output": "", + "negativeTest": false, "message": "SanitizerAPI with config: broken html, sanitize from document function for " }, { @@ -69,6 +76,7 @@ ], "inputType": "document", "output": "[object Object]", + "negativeTest": false, "message": "SanitizerAPI with config: empty object, sanitize from document function for " }, { @@ -78,6 +86,7 @@ ], "inputType": "document", "output": "1", + "negativeTest": false, "message": "SanitizerAPI with config: number, sanitize from document function for " }, { @@ -87,6 +96,7 @@ ], "inputType": "document", "output": "0", + "negativeTest": false, "message": "SanitizerAPI with config: zeros, sanitize from document function for " }, { @@ -96,6 +106,7 @@ ], "inputType": "document", "output": "3", + "negativeTest": false, "message": "SanitizerAPI with config: arithmetic, sanitize from document function for " }, { @@ -105,6 +116,7 @@ ], "inputType": "document", "output": "", + "negativeTest": false, "message": "SanitizerAPI with config: empty string, sanitize from document function for " }, { @@ -114,6 +126,7 @@ ], "inputType": "document", "output": "undefined", + "negativeTest": false, "message": "SanitizerAPI with config: undefined, sanitize from document function for " }, { @@ -123,6 +136,7 @@ ], "inputType": "document", "output": "test", + "negativeTest": false, "message": "SanitizerAPI with config: document, sanitize from document function for " }, { @@ -132,6 +146,7 @@ ], "inputType": "document", "output": "
test
", + "negativeTest": false, "message": "SanitizerAPI with config: html without close tag, sanitize from document function for " }, { @@ -141,6 +156,7 @@ ], "inputType": "document", "output": "", + "negativeTest": false, "message": "SanitizerAPI with config: scripts for default configs, sanitize from document function for " }, { @@ -150,6 +166,7 @@ ], "inputType": "document", "output": "hello", + "negativeTest": false, "message": "SanitizerAPI with config: script not as root, sanitize from document function for " }, { @@ -159,6 +176,7 @@ ], "inputType": "document", "output": "
hello
", + "negativeTest": false, "message": "SanitizerAPI with config: script deeper in the tree, sanitize from document function for " }, { @@ -168,6 +186,7 @@ ], "inputType": "document", "output": "

Click.

", + "negativeTest": false, "message": "SanitizerAPI with config: onclick scripts, sanitize from document function for " }, { @@ -177,6 +196,7 @@ ], "inputType": "document", "output": "<p>text</p>", + "negativeTest": false, "message": "SanitizerAPI with config: plaintext, sanitize from document function for " }, { @@ -186,6 +206,7 @@ ], "inputType": "document", "output": "TEXT", + "negativeTest": false, "message": "SanitizerAPI with config: xmp, sanitize from document function for " }, { @@ -197,6 +218,7 @@ ], "inputType": "document", "output": "test", + "negativeTest": false, "message": "SanitizerAPI with config: invalid config_input, sanitize from document function for " }, { @@ -208,6 +230,7 @@ ], "inputType": "document", "output": "test", + "negativeTest": false, "message": "SanitizerAPI with config: empty dropElements list, sanitize from document function for " }, { @@ -221,6 +244,7 @@ ], "inputType": "document", "output": "

bla

", + "negativeTest": false, "message": "SanitizerAPI with config: test html without close tag with dropElements list ['div'], sanitize from document function for " }, { @@ -230,6 +254,7 @@ ], "inputType": "document", "output": "bla", + "negativeTest": false, "message": "SanitizerAPI with config: default behavior for custom elements, sanitize from document function for " }, { @@ -241,6 +266,7 @@ ], "inputType": "document", "output": "testbla", + "negativeTest": false, "message": "SanitizerAPI with config: allow custom elements, sanitize from document function for " }, { @@ -255,6 +281,7 @@ ], "inputType": "document", "output": "testbla", + "negativeTest": false, "message": "SanitizerAPI with config: allow custom elements with allow elements, sanitize from document function for " }, { @@ -266,6 +293,7 @@ ], "inputType": "document", "output": "bla", + "negativeTest": false, "message": "SanitizerAPI with config: disallow custom elements, sanitize from document function for " }, { @@ -280,6 +308,7 @@ ], "inputType": "document", "output": "bla", + "negativeTest": false, "message": "SanitizerAPI with config: allow custom elements with drop list contains [\"custom-element\"], sanitize from document function for " }, { @@ -293,6 +322,7 @@ ], "inputType": "document", "output": "", + "negativeTest": false, "message": "SanitizerAPI with config: test script with [\"script\"] as dropElements list, sanitize from document function for " }, { @@ -307,6 +337,7 @@ ], "inputType": "document", "output": "
balabala
", + "negativeTest": false, "message": "SanitizerAPI with config: dropElements list [\"test-element\", \"i\"]}, sanitize from document function for " }, { @@ -321,6 +352,7 @@ ], "inputType": "document", "output": "
balabalai
", + "negativeTest": false, "message": "SanitizerAPI with config: dropElements list [\"dl\", \"p\"]}, sanitize from document function for " }, { @@ -334,6 +366,7 @@ ], "inputType": "document", "output": "testptt

div

", + "negativeTest": false, "message": "SanitizerAPI with config: allowElements list [\"p\"], sanitize from document function for " }, { @@ -350,6 +383,7 @@ ], "inputType": "document", "output": "bla", + "negativeTest": false, "message": "SanitizerAPI with config: allowElements list has no influence to dropElements, sanitize from document function for " }, { @@ -368,6 +402,7 @@ ], "inputType": "document", "output": "

Click.

div
", + "negativeTest": false, "message": "SanitizerAPI with config: dropAttributes list {\"style\": [\"p\"]} with style attribute, sanitize from document function for " }, { @@ -379,6 +414,7 @@ ], "inputType": "document", "output": "

Click.

", + "negativeTest": false, "message": "SanitizerAPI with config: empty dropAttributes list with id attribute, sanitize from document function for " }, { @@ -395,6 +431,7 @@ ], "inputType": "document", "output": "

Click.

", + "negativeTest": false, "message": "SanitizerAPI with config: dropAttributes list {\"id\": [\"*\"]} with id attribute, sanitize from document function for " }, { @@ -411,6 +448,7 @@ ], "inputType": "document", "output": "

Click.

", + "negativeTest": false, "message": "SanitizerAPI with config: dropAttributes list {\"data-attribute-with-dashes\": [\"*\"]} with dom dataset js access, sanitize from document function for " }, { @@ -429,6 +467,7 @@ ], "inputType": "document", "output": "

P

DIV
", + "negativeTest": false, "message": "SanitizerAPI with config: allowAttributes list {\"id\": [\"div\"]} with id attribute, sanitize from document function for " }, { @@ -445,6 +484,7 @@ ], "inputType": "document", "output": "

Click.

", + "negativeTest": false, "message": "SanitizerAPI with config: allowAttributes list {\"id\": [\"*\"]} with id attribute and onclick scripts, sanitize from document function for " }, { @@ -467,6 +507,7 @@ ], "inputType": "document", "output": "

Click.

", + "negativeTest": false, "message": "SanitizerAPI with config: allowAttributes list has no influence to dropAttributes, sanitize from document function for " }, { @@ -481,6 +522,7 @@ ], "inputType": "document", "output": "", + "negativeTest": false, "message": "SanitizerAPI with config: Template element, sanitize from document function for " }, { @@ -490,6 +532,7 @@ ], "inputType": "document", "output": "Click.", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLAnchorElement with javascript protocal, sanitize from document function for " }, { @@ -499,6 +542,7 @@ ], "inputType": "document", "output": "Click.", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLAnchorElement with javascript protocal start with space, sanitize from document function for " }, { @@ -508,6 +552,7 @@ ], "inputType": "document", "output": "Click.", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLAnchorElement, sanitize from document function for " }, { @@ -517,6 +562,7 @@ ], "inputType": "document", "output": "Click.", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLAreaElement with javascript protocal, sanitize from document function for " }, { @@ -526,6 +572,7 @@ ], "inputType": "document", "output": "Click.", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLAreaElement with javascript protocal start with space, sanitize from document function for " }, { @@ -535,6 +582,7 @@ ], "inputType": "document", "output": "Click.", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLAreaElement, sanitize from document function for " }, { @@ -544,6 +592,7 @@ ], "inputType": "document", "output": "
Click.
", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLFormElement with javascript action, sanitize from document function for " }, { @@ -553,6 +602,7 @@ ], "inputType": "document", "output": "
Click.
", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLFormElement with javascript action start with space, sanitize from document function for " }, { @@ -562,6 +612,7 @@ ], "inputType": "document", "output": "
Click.
", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLFormElement, sanitize from document function for " }, { @@ -571,6 +622,7 @@ ], "inputType": "document", "output": "Click.", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLInputElement with javascript formaction, sanitize from document function for " }, { @@ -580,6 +632,7 @@ ], "inputType": "document", "output": "Click.", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLInputElement with javascript formaction start with space, sanitize from document function for " }, { @@ -589,6 +642,7 @@ ], "inputType": "document", "output": "Click.", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLInputElement, sanitize from document function for " }, { @@ -598,6 +652,7 @@ ], "inputType": "document", "output": "", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLButtonElement with javascript formaction, sanitize from document function for " }, { @@ -607,6 +662,7 @@ ], "inputType": "document", "output": "", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLButtonElement with javascript formaction start with space, sanitize from document function for " }, { @@ -616,6 +672,7 @@ ], "inputType": "document", "output": "", + "negativeTest": false, "message": "SanitizerAPI with config: HTMLButtonElement, sanitize from document function for " }, { @@ -625,6 +682,7 @@ ], "inputType": "document", "output": "

Some text

Some more text

", + "negativeTest": false, "message": "SanitizerAPI with config: malformed HTML, sanitize from document function for " }, { @@ -634,6 +692,7 @@ ], "inputType": "document", "output": "

Some text

Some more text

", + "negativeTest": false, "message": "SanitizerAPI with config: HTML with comments; comments not allowed, sanitize from document function for " }, { @@ -645,6 +704,7 @@ ], "inputType": "document", "output": "

Some text

Some more text

", + "negativeTest": false, "message": "SanitizerAPI with config: HTML with comments; allowComments, sanitize from document function for " }, { @@ -656,6 +716,7 @@ ], "inputType": "document", "output": "

Some text

Some more text

", + "negativeTest": false, "message": "SanitizerAPI with config: HTML with comments; !allowComments, sanitize from document function for " }, { @@ -665,6 +726,7 @@ ], "inputType": "document", "output": "

commentintext

", + "negativeTest": false, "message": "SanitizerAPI with config: HTML with comments deeper in the tree, sanitize from document function for " }, { @@ -676,6 +738,7 @@ ], "inputType": "document", "output": "

commentintext

", + "negativeTest": false, "message": "SanitizerAPI with config: HTML with comments deeper in the tree, allowComments, sanitize from document function for " }, { @@ -687,6 +750,7 @@ ], "inputType": "document", "output": "

commentintext

", + "negativeTest": false, "message": "SanitizerAPI with config: HTML with comments deeper in the tree, !allowComments, sanitize from document function for " }, { @@ -700,6 +764,7 @@ ], "inputType": "document", "output": "", + "negativeTest": false, "message": "SanitizerAPI with config: Unknown HTML names (HTMLUnknownElement instances) should not match elements parsed as non-HTML namespaces., sanitize from document function for " }, { @@ -714,6 +779,7 @@ ], "inputType": "document", "output": "
", + "negativeTest": false, "message": "SanitizerAPI with config: Unknown HTML names (HTMLUnknownElement instances) should not match elements parsed as non-HTML namespaces when nested., sanitize from document function for " }, { @@ -728,6 +794,7 @@ ], "inputType": "document", "output": "
balabala
test
", + "negativeTest": false, "message": "SanitizerAPI with config: dropElements list [\"I\", \"DL\"]}, sanitize from document function for " }, { @@ -742,6 +809,7 @@ ], "inputType": "document", "output": "
balabala
", + "negativeTest": false, "message": "SanitizerAPI with config: dropElements list [\"i\", \"dl\"]}, sanitize from document function for " }, { @@ -756,6 +824,7 @@ ], "inputType": "document", "output": "
balabala
", + "negativeTest": false, "message": "SanitizerAPI with config: dropElements list [\"i\", \"dl\"]} with uppercase HTML, sanitize from document function for " }, { @@ -772,6 +841,7 @@ ], "inputType": "document", "output": "

Click.

", + "negativeTest": false, "message": "SanitizerAPI with config: dropAttributes list {\"ID\": [\"*\"]} with id attribute, sanitize from document function for " }, { @@ -788,6 +858,7 @@ ], "inputType": "document", "output": "

Click.

", + "negativeTest": false, "message": "SanitizerAPI with config: dropAttributes list {\"ID\": [\"*\"]} with ID attribute, sanitize from document function for " }, { @@ -804,6 +875,7 @@ ], "inputType": "document", "output": "

Click.

", + "negativeTest": false, "message": "SanitizerAPI with config: dropAttributes list {\"id\": [\"*\"]} with ID attribute, sanitize from document function for " }, { @@ -820,6 +892,7 @@ ], "inputType": "document", "output": "
balabala
", + "negativeTest": false, "message": "SanitizerAPI with config: dropElements with unknown elements and without allowUnknownMarkup, sanitize from document function for " }, { @@ -836,6 +909,7 @@ ], "inputType": "document", "output": "
balabalatest
", + "negativeTest": false, "message": "SanitizerAPI with config: blockElements with unknown elements and without allowUnknownMarkup, sanitize from document function for " }, { @@ -850,6 +924,7 @@ ], "inputType": "document", "output": "testptt

div

", + "negativeTest": false, "message": "SanitizerAPI with config: allowElements with unknown elements and without allowUnknownMarkup, sanitize from document function for " }, { @@ -867,6 +942,7 @@ ], "inputType": "document", "output": "
balabala
", + "negativeTest": false, "message": "SanitizerAPI with config: dropElements with unknown elements and with allowUnknownMarkup, sanitize from document function for " }, { @@ -884,6 +960,7 @@ ], "inputType": "document", "output": "
balabalatest
t", + "negativeTest": false, "message": "SanitizerAPI with config: blockElements with unknown elements and with allowUnknownMarkup, sanitize from document function for " }, { @@ -899,6 +976,7 @@ ], "inputType": "document", "output": "testptt

div

test", + "negativeTest": false, "message": "SanitizerAPI with config: allowElements with unknown elements and with allowUnknownMarkup, sanitize from document function for " }, { @@ -921,6 +999,7 @@ ], "inputType": "document", "output": "
", + "negativeTest": false, "message": "SanitizerAPI with config: allowAttributes unknown attributes and without allowUnknownMarkup, sanitize from document function for " }, { @@ -944,6 +1023,7 @@ ], "inputType": "document", "output": "
", + "negativeTest": false, "message": "SanitizerAPI with config: allowAttributes unknown attributes and with allowUnknownMarkup, sanitize from document function for " }, { @@ -966,6 +1046,7 @@ ], "inputType": "document", "output": "
", + "negativeTest": false, "message": "SanitizerAPI with config: dropAttributes unknown attributes and without allowUnknownMarkup, sanitize from document function for " }, { @@ -989,6 +1070,7 @@ ], "inputType": "document", "output": "
", + "negativeTest": false, "message": "SanitizerAPI with config: dropAttributes unknown attributes and with allowUnknownMarkup, sanitize from document function for " }, { @@ -996,6 +1078,7 @@ "input": "test", "inputType": "template-content", "output": "test", + "negativeTest": false, "message": "SanitizerAPI with config: string, sanitize from document fragment function for