From f88f41cf1eba90aa3208d0cbe89a23e0fde9fbaa Mon Sep 17 00:00:00 2001 From: Gingeh <39150378+Gingeh@users.noreply.github.com> Date: Wed, 6 Nov 2024 22:01:36 +1100 Subject: [PATCH] LibWeb: Reject invalid processing instructions --- ...ment-createProcessingInstruction-xhtml.txt | 22 +++++++++++ .../Document-createProcessingInstruction.txt | 22 +++++++++++ ...nt-createProcessingInstruction-xhtml.xhtml | 15 +++++++ .../Document-createProcessingInstruction.html | 11 ++++++ .../Document-createProcessingInstruction.js | 39 +++++++++++++++++++ Userland/Libraries/LibWeb/DOM/Document.cpp | 8 +++- 6 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Document-createProcessingInstruction-xhtml.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Document-createProcessingInstruction.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/dom/nodes/Document-createProcessingInstruction-xhtml.xhtml create mode 100644 Tests/LibWeb/Text/input/wpt-import/dom/nodes/Document-createProcessingInstruction.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/dom/nodes/Document-createProcessingInstruction.js diff --git a/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Document-createProcessingInstruction-xhtml.txt b/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Document-createProcessingInstruction-xhtml.txt new file mode 100644 index 00000000000..5c18a38fa32 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Document-createProcessingInstruction-xhtml.txt @@ -0,0 +1,22 @@ +Summary + +Harness status: OK + +Rerun + +Found 12 tests + +12 Pass +Details +Result Test Name MessagePass Document.createProcessingInstruction in XML documents +Pass Should throw an INVALID_CHARACTER_ERR for target "A" and data "?>". +Pass Should throw an INVALID_CHARACTER_ERR for target "·A" and data "x". +Pass Should throw an INVALID_CHARACTER_ERR for target "×A" and data "x". +Pass Should throw an INVALID_CHARACTER_ERR for target "A×" and data "x". +Pass Should throw an INVALID_CHARACTER_ERR for target "\\A" and data "x". +Pass Should throw an INVALID_CHARACTER_ERR for target "\f" and data "x". +Pass Should throw an INVALID_CHARACTER_ERR for target 0 and data "x". +Pass Should throw an INVALID_CHARACTER_ERR for target "0" and data "x". +Pass Should get a ProcessingInstruction for target "xml:fail" and data "x". +Pass Should get a ProcessingInstruction for target "A·A" and data "x". +Pass Should get a ProcessingInstruction for target "a0" and data "x". \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Document-createProcessingInstruction.txt b/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Document-createProcessingInstruction.txt new file mode 100644 index 00000000000..257ee6d1929 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Document-createProcessingInstruction.txt @@ -0,0 +1,22 @@ +Summary + +Harness status: OK + +Rerun + +Found 12 tests + +12 Pass +Details +Result Test Name MessagePass Document.createProcessingInstruction in HTML documents +Pass Should throw an INVALID_CHARACTER_ERR for target "A" and data "?>". +Pass Should throw an INVALID_CHARACTER_ERR for target "·A" and data "x". +Pass Should throw an INVALID_CHARACTER_ERR for target "×A" and data "x". +Pass Should throw an INVALID_CHARACTER_ERR for target "A×" and data "x". +Pass Should throw an INVALID_CHARACTER_ERR for target "\\A" and data "x". +Pass Should throw an INVALID_CHARACTER_ERR for target "\f" and data "x". +Pass Should throw an INVALID_CHARACTER_ERR for target 0 and data "x". +Pass Should throw an INVALID_CHARACTER_ERR for target "0" and data "x". +Pass Should get a ProcessingInstruction for target "xml:fail" and data "x". +Pass Should get a ProcessingInstruction for target "A·A" and data "x". +Pass Should get a ProcessingInstruction for target "a0" and data "x". \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/dom/nodes/Document-createProcessingInstruction-xhtml.xhtml b/Tests/LibWeb/Text/input/wpt-import/dom/nodes/Document-createProcessingInstruction-xhtml.xhtml new file mode 100644 index 00000000000..287be72601d --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/dom/nodes/Document-createProcessingInstruction-xhtml.xhtml @@ -0,0 +1,15 @@ + +
+