From 9850b243624e1a83e2eb7dcab499e107a47f164e Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Tue, 15 Nov 2022 20:10:58 +0300 Subject: [PATCH] fix(xml/parser): comment parsing --- crates/swc_xml_parser/src/error.rs | 2 + crates/swc_xml_parser/src/lexer/mod.rs | 1 + .../tests/fixture/comments/dom.rust-debug | 43 ++ .../tests/fixture/comments/input.xml | 17 + .../tests/fixture/comments/output.json | 302 ++++++++++ .../tests/fixture/comments/span.rust-debug | 397 ++++++++++++ .../recovery/comments/bad-1/dom.rust-debug | 7 + .../tests/recovery/comments/bad-1/input.xml | 5 + .../tests/recovery/comments/bad-1/output.json | 62 ++ .../recovery/comments/bad-1/output.stderr | 6 + .../recovery/comments/bad-1/span.rust-debug | 73 +++ .../recovery/comments/bad-10/dom.rust-debug | 8 + .../tests/recovery/comments/bad-10/input.xml | 5 + .../recovery/comments/bad-10/output.json | 52 ++ .../recovery/comments/bad-10/output.stderr | 12 + .../recovery/comments/bad-10/span.rust-debug | 63 ++ .../recovery/comments/bad-11/dom.rust-debug | 8 + .../tests/recovery/comments/bad-11/input.xml | 5 + .../recovery/comments/bad-11/output.json | 52 ++ .../recovery/comments/bad-11/output.stderr | 12 + .../recovery/comments/bad-11/span.rust-debug | 63 ++ .../recovery/comments/bad-12/dom.rust-debug | 8 + .../tests/recovery/comments/bad-12/input.xml | 5 + .../recovery/comments/bad-12/output.json | 52 ++ .../recovery/comments/bad-12/output.stderr | 19 + .../recovery/comments/bad-12/span.rust-debug | 63 ++ .../recovery/comments/bad-13/dom.rust-debug | 8 + .../tests/recovery/comments/bad-13/input.xml | 5 + .../recovery/comments/bad-13/output.json | 52 ++ .../recovery/comments/bad-13/output.stderr | 18 + .../recovery/comments/bad-13/span.rust-debug | 63 ++ .../recovery/comments/bad-14/dom.rust-debug | 7 + .../tests/recovery/comments/bad-14/input.xml | 5 + .../recovery/comments/bad-14/output.json | 62 ++ .../recovery/comments/bad-14/output.stderr | 12 + .../recovery/comments/bad-14/span.rust-debug | 73 +++ .../recovery/comments/bad-15/dom.rust-debug | 8 + .../tests/recovery/comments/bad-15/input.xml | 5 + .../recovery/comments/bad-15/output.json | 52 ++ .../recovery/comments/bad-15/output.stderr | 24 + .../recovery/comments/bad-15/span.rust-debug | 63 ++ .../recovery/comments/bad-16/dom.rust-debug | 8 + .../tests/recovery/comments/bad-16/input.xml | 5 + .../recovery/comments/bad-16/output.json | 52 ++ .../recovery/comments/bad-16/output.stderr | 18 + .../recovery/comments/bad-16/span.rust-debug | 63 ++ .../recovery/comments/bad-17/dom.rust-debug | 8 + .../tests/recovery/comments/bad-17/input.xml | 5 + .../recovery/comments/bad-17/output.json | 52 ++ .../recovery/comments/bad-17/output.stderr | 18 + .../recovery/comments/bad-17/span.rust-debug | 63 ++ .../recovery/comments/bad-18/dom.rust-debug | 8 + .../tests/recovery/comments/bad-18/input.xml | 5 + .../recovery/comments/bad-18/output.json | 52 ++ .../recovery/comments/bad-18/output.stderr | 18 + .../recovery/comments/bad-18/span.rust-debug | 63 ++ .../recovery/comments/bad-19/dom.rust-debug | 7 + .../tests/recovery/comments/bad-19/input.xml | 5 + .../recovery/comments/bad-19/output.json | 62 ++ .../recovery/comments/bad-19/output.stderr | 6 + .../recovery/comments/bad-19/span.rust-debug | 73 +++ .../recovery/comments/bad-2/dom.rust-debug | 8 + .../tests/recovery/comments/bad-2/input.xml | 5 + .../tests/recovery/comments/bad-2/output.json | 52 ++ .../recovery/comments/bad-2/output.stderr | 12 + .../recovery/comments/bad-2/span.rust-debug | 63 ++ .../recovery/comments/bad-20/dom.rust-debug | 8 + .../tests/recovery/comments/bad-20/input.xml | 5 + .../recovery/comments/bad-20/output.json | 52 ++ .../recovery/comments/bad-20/output.stderr | 12 + .../recovery/comments/bad-20/span.rust-debug | 63 ++ .../recovery/comments/bad-21/dom.rust-debug | 8 + .../tests/recovery/comments/bad-21/input.xml | 5 + .../recovery/comments/bad-21/output.json | 52 ++ .../recovery/comments/bad-21/output.stderr | 12 + .../recovery/comments/bad-21/span.rust-debug | 63 ++ .../recovery/comments/bad-22/dom.rust-debug | 8 + .../tests/recovery/comments/bad-22/input.xml | 5 + .../recovery/comments/bad-22/output.json | 52 ++ .../recovery/comments/bad-22/output.stderr | 12 + .../recovery/comments/bad-22/span.rust-debug | 63 ++ .../recovery/comments/bad-23/dom.rust-debug | 8 + .../tests/recovery/comments/bad-23/input.xml | 5 + .../recovery/comments/bad-23/output.json | 52 ++ .../recovery/comments/bad-23/output.stderr | 12 + .../recovery/comments/bad-23/span.rust-debug | 63 ++ .../recovery/comments/bad-24/dom.rust-debug | 8 + .../tests/recovery/comments/bad-24/input.xml | 5 + .../recovery/comments/bad-24/output.json | 52 ++ .../recovery/comments/bad-24/output.stderr | 12 + .../recovery/comments/bad-24/span.rust-debug | 63 ++ .../recovery/comments/bad-25/dom.rust-debug | 8 + .../tests/recovery/comments/bad-25/input.xml | 5 + .../recovery/comments/bad-25/output.json | 52 ++ .../recovery/comments/bad-25/output.stderr | 12 + .../recovery/comments/bad-25/span.rust-debug | 63 ++ .../recovery/comments/bad-26/dom.rust-debug | 7 + .../tests/recovery/comments/bad-26/input.xml | 5 + .../recovery/comments/bad-26/output.json | 62 ++ .../recovery/comments/bad-26/output.stderr | 6 + .../recovery/comments/bad-26/span.rust-debug | 73 +++ .../recovery/comments/bad-27/dom.rust-debug | 7 + .../tests/recovery/comments/bad-27/input.xml | 5 + .../recovery/comments/bad-27/output.json | 62 ++ .../recovery/comments/bad-27/output.stderr | 6 + .../recovery/comments/bad-27/span.rust-debug | 73 +++ .../recovery/comments/bad-28/dom.rust-debug | 7 + .../tests/recovery/comments/bad-28/input.xml | 5 + .../recovery/comments/bad-28/output.json | 62 ++ .../recovery/comments/bad-28/output.stderr | 6 + .../recovery/comments/bad-28/span.rust-debug | 73 +++ .../recovery/comments/bad-29/dom.rust-debug | 8 + .../tests/recovery/comments/bad-29/input.xml | 5 + .../recovery/comments/bad-29/output.json | 52 ++ .../recovery/comments/bad-29/output.stderr | 12 + .../recovery/comments/bad-29/span.rust-debug | 63 ++ .../recovery/comments/bad-3/dom.rust-debug | 8 + .../tests/recovery/comments/bad-3/input.xml | 5 + .../tests/recovery/comments/bad-3/output.json | 52 ++ .../recovery/comments/bad-3/output.stderr | 12 + .../recovery/comments/bad-3/span.rust-debug | 63 ++ .../recovery/comments/bad-30/dom.rust-debug | 8 + .../tests/recovery/comments/bad-30/input.xml | 5 + .../recovery/comments/bad-30/output.json | 52 ++ .../recovery/comments/bad-30/output.stderr | 12 + .../recovery/comments/bad-30/span.rust-debug | 63 ++ .../recovery/comments/bad-31/dom.rust-debug | 8 + .../tests/recovery/comments/bad-31/input.xml | 5 + .../recovery/comments/bad-31/output.json | 52 ++ .../recovery/comments/bad-31/output.stderr | 18 + .../recovery/comments/bad-31/span.rust-debug | 63 ++ .../recovery/comments/bad-32/dom.rust-debug | 7 + .../tests/recovery/comments/bad-32/input.xml | 5 + .../recovery/comments/bad-32/output.json | 62 ++ .../recovery/comments/bad-32/output.stderr | 6 + .../recovery/comments/bad-32/span.rust-debug | 73 +++ .../recovery/comments/bad-33/dom.rust-debug | 7 + .../tests/recovery/comments/bad-33/input.xml | 5 + .../recovery/comments/bad-33/output.json | 62 ++ .../recovery/comments/bad-33/output.stderr | 12 + .../recovery/comments/bad-33/span.rust-debug | 73 +++ .../recovery/comments/bad-34/dom.rust-debug | 7 + .../tests/recovery/comments/bad-34/input.xml | 5 + .../recovery/comments/bad-34/output.json | 62 ++ .../recovery/comments/bad-34/output.stderr | 6 + .../recovery/comments/bad-34/span.rust-debug | 73 +++ .../recovery/comments/bad-35/dom.rust-debug | 7 + .../tests/recovery/comments/bad-35/input.xml | 5 + .../recovery/comments/bad-35/output.json | 62 ++ .../recovery/comments/bad-35/output.stderr | 6 + .../recovery/comments/bad-35/span.rust-debug | 73 +++ .../recovery/comments/bad-36/dom.rust-debug | 7 + .../tests/recovery/comments/bad-36/input.xml | 5 + .../recovery/comments/bad-36/output.json | 62 ++ .../recovery/comments/bad-36/output.stderr | 6 + .../recovery/comments/bad-36/span.rust-debug | 73 +++ .../recovery/comments/bad-37/dom.rust-debug | 7 + .../tests/recovery/comments/bad-37/input.xml | 5 + .../recovery/comments/bad-37/output.json | 62 ++ .../recovery/comments/bad-37/output.stderr | 6 + .../recovery/comments/bad-37/span.rust-debug | 73 +++ .../recovery/comments/bad-38/dom.rust-debug | 7 + .../tests/recovery/comments/bad-38/input.xml | 5 + .../recovery/comments/bad-38/output.json | 62 ++ .../recovery/comments/bad-38/output.stderr | 6 + .../recovery/comments/bad-38/span.rust-debug | 73 +++ .../recovery/comments/bad-39/dom.rust-debug | 7 + .../tests/recovery/comments/bad-39/input.xml | 5 + .../recovery/comments/bad-39/output.json | 62 ++ .../recovery/comments/bad-39/output.stderr | 12 + .../recovery/comments/bad-39/span.rust-debug | 73 +++ .../recovery/comments/bad-4/dom.rust-debug | 7 + .../tests/recovery/comments/bad-4/input.xml | 5 + .../tests/recovery/comments/bad-4/output.json | 62 ++ .../recovery/comments/bad-4/output.stderr | 6 + .../recovery/comments/bad-4/span.rust-debug | 73 +++ .../recovery/comments/bad-40/dom.rust-debug | 62 ++ .../tests/recovery/comments/bad-40/input.xml | 18 + .../recovery/comments/bad-40/output.json | 541 +++++++++++++++++ .../recovery/comments/bad-40/output.stderr | 24 + .../recovery/comments/bad-40/span.rust-debug | 564 ++++++++++++++++++ .../recovery/comments/bad-5/dom.rust-debug | 8 + .../tests/recovery/comments/bad-5/input.xml | 5 + .../tests/recovery/comments/bad-5/output.json | 52 ++ .../recovery/comments/bad-5/output.stderr | 18 + .../recovery/comments/bad-5/span.rust-debug | 63 ++ .../recovery/comments/bad-6/dom.rust-debug | 7 + .../tests/recovery/comments/bad-6/input.xml | 5 + .../tests/recovery/comments/bad-6/output.json | 62 ++ .../recovery/comments/bad-6/output.stderr | 6 + .../recovery/comments/bad-6/span.rust-debug | 73 +++ .../recovery/comments/bad-7/dom.rust-debug | 8 + .../tests/recovery/comments/bad-7/input.xml | 5 + .../tests/recovery/comments/bad-7/output.json | 52 ++ .../recovery/comments/bad-7/output.stderr | 12 + .../recovery/comments/bad-7/span.rust-debug | 63 ++ .../recovery/comments/bad-8/dom.rust-debug | 8 + .../tests/recovery/comments/bad-8/input.xml | 5 + .../tests/recovery/comments/bad-8/output.json | 52 ++ .../recovery/comments/bad-8/output.stderr | 12 + .../recovery/comments/bad-8/span.rust-debug | 63 ++ .../recovery/comments/bad-9/dom.rust-debug | 8 + .../tests/recovery/comments/bad-9/input.xml | 5 + .../tests/recovery/comments/bad-9/output.json | 52 ++ .../recovery/comments/bad-9/output.stderr | 12 + .../recovery/comments/bad-9/span.rust-debug | 63 ++ 206 files changed, 7712 insertions(+) create mode 100644 crates/swc_xml_parser/tests/fixture/comments/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/fixture/comments/input.xml create mode 100644 crates/swc_xml_parser/tests/fixture/comments/output.json create mode 100644 crates/swc_xml_parser/tests/fixture/comments/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-1/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-1/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-1/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-1/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-1/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-10/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-10/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-10/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-10/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-10/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-11/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-11/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-11/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-11/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-11/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-12/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-12/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-12/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-12/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-12/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-13/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-13/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-13/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-13/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-13/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-14/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-14/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-14/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-14/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-14/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-15/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-15/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-15/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-15/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-15/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-16/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-16/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-16/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-16/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-16/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-17/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-17/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-17/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-17/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-17/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-18/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-18/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-18/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-18/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-18/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-19/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-19/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-19/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-19/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-19/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-2/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-2/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-2/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-2/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-2/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-20/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-20/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-20/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-20/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-20/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-21/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-21/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-21/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-21/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-21/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-22/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-22/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-22/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-22/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-22/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-23/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-23/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-23/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-23/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-23/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-24/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-24/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-24/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-24/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-24/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-25/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-25/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-25/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-25/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-25/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-26/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-26/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-26/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-26/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-26/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-27/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-27/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-27/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-27/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-27/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-28/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-28/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-28/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-28/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-28/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-29/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-29/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-29/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-29/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-29/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-3/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-3/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-3/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-3/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-3/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-30/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-30/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-30/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-30/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-30/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-31/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-31/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-31/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-31/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-31/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-32/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-32/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-32/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-32/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-32/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-33/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-33/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-33/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-33/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-33/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-34/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-34/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-34/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-34/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-34/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-35/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-35/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-35/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-35/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-35/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-36/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-36/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-36/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-36/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-36/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-37/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-37/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-37/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-37/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-37/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-38/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-38/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-38/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-38/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-38/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-39/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-39/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-39/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-39/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-39/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-4/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-4/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-4/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-4/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-4/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-40/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-40/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-40/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-40/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-40/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-5/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-5/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-5/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-5/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-5/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-6/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-6/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-6/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-6/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-6/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-7/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-7/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-7/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-7/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-7/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-8/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-8/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-8/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-8/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-8/span.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-9/dom.rust-debug create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-9/input.xml create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-9/output.json create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-9/output.stderr create mode 100644 crates/swc_xml_parser/tests/recovery/comments/bad-9/span.rust-debug diff --git a/crates/swc_xml_parser/src/error.rs b/crates/swc_xml_parser/src/error.rs index 84af58443af2..beb77ecad5d5 100644 --- a/crates/swc_xml_parser/src/error.rs +++ b/crates/swc_xml_parser/src/error.rs @@ -81,6 +81,7 @@ impl Error { "Missing whitespace between doctype public and system identifiers".into() } ErrorKind::NestedComment => "Nested comment".into(), + ErrorKind::DoubleHyphenWithInComment => "Double hyper within comment".into(), ErrorKind::NoncharacterInInputStream => "Noncharacter in input stream".into(), ErrorKind::SurrogateInInputStream => "Surrogate in input stream".into(), ErrorKind::SurrogateCharacterReference => "Surrogate character reference".into(), @@ -146,6 +147,7 @@ pub enum ErrorKind { MissingWhitespaceBeforeDoctypeName, MissingWhitespaceBetweenDoctypePublicAndSystemIdentifiers, NestedComment, + DoubleHyphenWithInComment, NoncharacterInInputStream, SurrogateInInputStream, SurrogateCharacterReference, diff --git a/crates/swc_xml_parser/src/lexer/mod.rs b/crates/swc_xml_parser/src/lexer/mod.rs index 4b0cee8ca4cf..9cc7fbe13e8b 100644 --- a/crates/swc_xml_parser/src/lexer/mod.rs +++ b/crates/swc_xml_parser/src/lexer/mod.rs @@ -1620,6 +1620,7 @@ where // Append a U+002D HYPHEN-MINUS character (-) to the comment token's data. Some(c @ '-') => { self.append_to_comment_token(c, c); + self.emit_error(ErrorKind::DoubleHyphenWithInComment); } // EOF // This is an eof-in-comment parse error. Emit the current comment token. diff --git a/crates/swc_xml_parser/tests/fixture/comments/dom.rust-debug b/crates/swc_xml_parser/tests/fixture/comments/dom.rust-debug new file mode 100644 index 000000000000..85f6a65ed484 --- /dev/null +++ b/crates/swc_xml_parser/tests/fixture/comments/dom.rust-debug @@ -0,0 +1,43 @@ + +| +| " + " +| +| " + " +| +| " + " +| +| " + " +| +| " + " +| +| " + " +| +| " + " +| +| " + " +| +| " + " +| +| " + " +| +| " + " +| +| " + " +| +| " + " +| +| " +" diff --git a/crates/swc_xml_parser/tests/fixture/comments/input.xml b/crates/swc_xml_parser/tests/fixture/comments/input.xml new file mode 100644 index 000000000000..77fc50e97741 --- /dev/null +++ b/crates/swc_xml_parser/tests/fixture/comments/input.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/crates/swc_xml_parser/tests/fixture/comments/output.json b/crates/swc_xml_parser/tests/fixture/comments/output.json new file mode 100644 index 000000000000..ababfb96ae4a --- /dev/null +++ b/crates/swc_xml_parser/tests/fixture/comments/output.json @@ -0,0 +1,302 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 264, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 262, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 65, + "ctxt": 0 + }, + "data": "comment", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 65, + "end": 70, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 70, + "end": 83, + "ctxt": 0 + }, + "data": "", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 83, + "end": 88, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 88, + "end": 99, + "ctxt": 0 + }, + "data": "" + }, + { + "type": "Text", + "span": { + "start": 99, + "end": 104, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 104, + "end": 114, + "ctxt": 0 + }, + "data": "" + }, + { + "type": "Text", + "span": { + "start": 114, + "end": 119, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 119, + "end": 130, + "ctxt": 0 + }, + "data": "<" + }, + { + "type": "Text", + "span": { + "start": 130, + "end": 135, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 135, + "end": 147, + "ctxt": 0 + }, + "data": "<" + }, + { + "type": "Text", + "span": { + "start": 147, + "end": 152, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 152, + "end": 161, + "ctxt": 0 + }, + "data": "" + }, + { + "type": "Text", + "span": { + "start": 161, + "end": 166, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 166, + "end": 175, + "ctxt": 0 + }, + "data": "<>", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 175, + "end": 180, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 180, + "end": 188, + "ctxt": 0 + }, + "data": "<", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 188, + "end": 193, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 193, + "end": 202, + "ctxt": 0 + }, + "data": "" + }, + { + "type": "Text", + "span": { + "start": 202, + "end": 207, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 207, + "end": 214, + "ctxt": 0 + }, + "data": "", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 214, + "end": 219, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 219, + "end": 232, + "ctxt": 0 + }, + "data": "-a->-a", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 232, + "end": 237, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 237, + "end": 254, + "ctxt": 0 + }, + "data": "-", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 254, + "end": 255, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/fixture/comments/span.rust-debug b/crates/swc_xml_parser/tests/fixture/comments/span.rust-debug new file mode 100644 index 000000000000..cde6f2053f71 --- /dev/null +++ b/crates/swc_xml_parser/tests/fixture/comments/span.rust-debug @@ -0,0 +1,397 @@ + + x Document + ,-[$DIR/tests/fixture/comments/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | | + 6 | | + 7 | | + 8 | | + 9 | | + 10 | | + 11 | | + 12 | | + 13 | | + 14 | | + 15 | | + 16 | | + 17 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/fixture/comments/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | | + 5 | | + 6 | | + 7 | | + 8 | | + 9 | | + 10 | | + 11 | | + 12 | | + 13 | | + 14 | | + 15 | | + 16 | `-> + `---- + + x Element + ,-[$DIR/tests/fixture/comments/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | | + 5 | | + 6 | | + 7 | | + 8 | | + 9 | | + 10 | | + 11 | | + 12 | | + 13 | | + 14 | | + 15 | | + 16 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/fixture/comments/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:3:5] + 3 | + : ^^^^^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/fixture/comments/input.xml:3:5] + 3 | + : ^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:3:5] + 3 | ,-> + 4 | `-> + `---- + + x Text + ,-[$DIR/tests/fixture/comments/input.xml:3:5] + 3 | ,-> + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:4:5] + 4 | + : ^^^^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/fixture/comments/input.xml:4:5] + 4 | + : ^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:4:5] + 4 | ,-> + 5 | `-> + `---- + + x Text + ,-[$DIR/tests/fixture/comments/input.xml:4:5] + 4 | ,-> + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:5:5] + 5 | + : ^^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/fixture/comments/input.xml:5:5] + 5 | + : ^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:5:5] + 5 | ,-> + 6 | `-> + `---- + + x Text + ,-[$DIR/tests/fixture/comments/input.xml:5:5] + 5 | ,-> + 6 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:6:5] + 6 | + : ^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/fixture/comments/input.xml:6:5] + 6 | + : ^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:6:5] + 6 | ,-> + 7 | `-> + `---- + + x Text + ,-[$DIR/tests/fixture/comments/input.xml:6:5] + 6 | ,-> + 7 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:7:5] + 7 | + : ^^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/fixture/comments/input.xml:7:5] + 7 | + : ^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:7:5] + 7 | ,-> + 8 | `-> + `---- + + x Text + ,-[$DIR/tests/fixture/comments/input.xml:7:5] + 7 | ,-> + 8 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:8:5] + 8 | + : ^^^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/fixture/comments/input.xml:8:5] + 8 | + : ^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:8:5] + 8 | ,-> + 9 | `-> + `---- + + x Text + ,-[$DIR/tests/fixture/comments/input.xml:8:5] + 8 | ,-> + 9 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:9:5] + 9 | + : ^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/fixture/comments/input.xml:9:5] + 9 | + : ^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:9:5] + 9 | ,-> + 10 | `-> + `---- + + x Text + ,-[$DIR/tests/fixture/comments/input.xml:9:5] + 9 | ,-> + 10 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:10:5] + 10 | + : ^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/fixture/comments/input.xml:10:5] + 10 | + : ^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:10:5] + 10 | ,-> + 11 | `-> + `---- + + x Text + ,-[$DIR/tests/fixture/comments/input.xml:10:5] + 10 | ,-> + 11 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:11:5] + 11 | + : ^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/fixture/comments/input.xml:11:5] + 11 | + : ^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:11:5] + 11 | ,-> + 12 | `-> + `---- + + x Text + ,-[$DIR/tests/fixture/comments/input.xml:11:5] + 11 | ,-> + 12 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:12:5] + 12 | + : ^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/fixture/comments/input.xml:12:5] + 12 | + : ^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:12:5] + 12 | ,-> + 13 | `-> + `---- + + x Text + ,-[$DIR/tests/fixture/comments/input.xml:12:5] + 12 | ,-> + 13 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:13:5] + 13 | + : ^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/fixture/comments/input.xml:13:5] + 13 | + : ^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:13:5] + 13 | ,-> + 14 | `-> + `---- + + x Text + ,-[$DIR/tests/fixture/comments/input.xml:13:5] + 13 | ,-> + 14 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:14:5] + 14 | + : ^^^^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/fixture/comments/input.xml:14:5] + 14 | + : ^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:14:5] + 14 | ,-> + 15 | `-> + `---- + + x Text + ,-[$DIR/tests/fixture/comments/input.xml:14:5] + 14 | ,-> + 15 | `-> + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:15:5] + 15 | + : ^^^^^^^^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/fixture/comments/input.xml:15:5] + 15 | + : ^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/fixture/comments/input.xml:15:5] + 15 | + : ^ + 16 | + `---- + + x Text + ,-[$DIR/tests/fixture/comments/input.xml:15:5] + 15 | + : ^ + 16 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-1/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-1/dom.rust-debug new file mode 100644 index 000000000000..e4dd0f8b1169 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-1/dom.rust-debug @@ -0,0 +1,7 @@ + +| +| " + " +| +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-1/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-1/input.xml new file mode 100644 index 000000000000..d5c294fa85b0 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-1/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-1/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-1/output.json new file mode 100644 index 000000000000..d623a1f954dd --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-1/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 69, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 67, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 59, + "ctxt": 0 + }, + "data": "", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 59, + "end": 60, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-1/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-1/output.stderr new file mode 100644 index 000000000000..e62502c00b2e --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-1/output.stderr @@ -0,0 +1,6 @@ + + x Incorrectly closed comment + ,-[$DIR/tests/recovery/comments/bad-1/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-1/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-1/span.rust-debug new file mode 100644 index 000000000000..4426acd62ea4 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-1/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-1/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-1/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-1/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-1/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-1/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-1/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-1/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-1/input.xml:3:5] + 3 | + : ^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-1/input.xml:3:5] + 3 | + : ^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-1/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-1/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-10/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-10/dom.rust-debug new file mode 100644 index 000000000000..e385c08e65a8 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-10/dom.rust-debug @@ -0,0 +1,8 @@ + +| +| " + " +| diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-10/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-10/input.xml new file mode 100644 index 000000000000..6a4aae61864b --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-10/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-11/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-11/input.xml new file mode 100644 index 000000000000..0b2a8ea0ff52 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-11/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-12/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-12/input.xml new file mode 100644 index 000000000000..c8bbff2f35a0 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-12/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-13/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-13/input.xml new file mode 100644 index 000000000000..04927df80c37 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-13/input.xml @@ -0,0 +1,5 @@ + + + +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-14/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-14/input.xml new file mode 100644 index 000000000000..7818a1062757 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-14/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-14/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-14/output.json new file mode 100644 index 000000000000..5a8bea6455d7 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-14/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 71, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 69, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 61, + "ctxt": 0 + }, + "data": "" + }, + { + "type": "Text", + "span": { + "start": 61, + "end": 62, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-14/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-14/output.stderr new file mode 100644 index 000000000000..55b0db51ffa1 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-14/output.stderr @@ -0,0 +1,12 @@ + + x Nested comment + ,-[$DIR/tests/recovery/comments/bad-14/input.xml:3:5] + 3 | + : ^ + `---- + + x Incorrectly closed comment + ,-[$DIR/tests/recovery/comments/bad-14/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-14/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-14/span.rust-debug new file mode 100644 index 000000000000..fc1afbddf4e5 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-14/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-14/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-14/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-14/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-14/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-14/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-14/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-14/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-14/input.xml:3:5] + 3 | + : ^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-14/input.xml:3:5] + 3 | + : ^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-14/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-14/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-15/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-15/dom.rust-debug new file mode 100644 index 000000000000..51285fcd7c9a --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-15/dom.rust-debug @@ -0,0 +1,8 @@ + +| +| " + " +| diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-15/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-15/input.xml new file mode 100644 index 000000000000..edd7faf28092 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-15/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-16/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-16/input.xml new file mode 100644 index 000000000000..f7e32e82304a --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-16/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-17/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-17/input.xml new file mode 100644 index 000000000000..28c20301eaa3 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-17/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-18/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-18/input.xml new file mode 100644 index 000000000000..b78e5666a5b1 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-18/input.xml @@ -0,0 +1,5 @@ + + + +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-19/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-19/input.xml new file mode 100644 index 000000000000..0ca5dd478ab4 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-19/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-19/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-19/output.json new file mode 100644 index 000000000000..e41cb8bc0cd6 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-19/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 73, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 71, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 63, + "ctxt": 0 + }, + "data": "" + }, + { + "type": "Text", + "span": { + "start": 63, + "end": 64, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-19/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-19/output.stderr new file mode 100644 index 000000000000..03b849cbd014 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-19/output.stderr @@ -0,0 +1,6 @@ + + x Nested comment + ,-[$DIR/tests/recovery/comments/bad-19/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-19/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-19/span.rust-debug new file mode 100644 index 000000000000..ff512885fbf4 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-19/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-19/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-19/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-19/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-19/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-19/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-19/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-19/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-19/input.xml:3:5] + 3 | + : ^^^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-19/input.xml:3:5] + 3 | + : ^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-19/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-19/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-2/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-2/dom.rust-debug new file mode 100644 index 000000000000..77ffd9e2b4aa --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-2/dom.rust-debug @@ -0,0 +1,8 @@ + +| +| " + " +| diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-2/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-2/input.xml new file mode 100644 index 000000000000..9ee4229d0aa1 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-2/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-20/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-20/input.xml new file mode 100644 index 000000000000..02d52824cf5a --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-20/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-21/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-21/input.xml new file mode 100644 index 000000000000..2bb55719e058 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-21/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-22/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-22/input.xml new file mode 100644 index 000000000000..ee098ee90c9c --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-22/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-23/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-23/input.xml new file mode 100644 index 000000000000..38774471fe09 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-23/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-24/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-24/input.xml new file mode 100644 index 000000000000..dc5130b2f446 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-24/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-25/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-25/input.xml new file mode 100644 index 000000000000..4b252df0f15f --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-25/input.xml @@ -0,0 +1,5 @@ + + + +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-26/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-26/input.xml new file mode 100644 index 000000000000..2d09b113f7f6 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-26/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-26/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-26/output.json new file mode 100644 index 000000000000..730da11fb621 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-26/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 74, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 72, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 64, + "ctxt": 0 + }, + "data": "<" + }, + { + "type": "Text", + "span": { + "start": 64, + "end": 65, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-26/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-26/output.stderr new file mode 100644 index 000000000000..55d39197adec --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-26/output.stderr @@ -0,0 +1,6 @@ + + x Nested comment + ,-[$DIR/tests/recovery/comments/bad-26/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-26/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-26/span.rust-debug new file mode 100644 index 000000000000..b1c6e8f7dc11 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-26/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-26/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-26/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-26/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-26/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-26/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-26/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-26/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-26/input.xml:3:5] + 3 | + : ^^^^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-26/input.xml:3:5] + 3 | + : ^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-26/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-26/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-27/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-27/dom.rust-debug new file mode 100644 index 000000000000..50d2b53e39f1 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-27/dom.rust-debug @@ -0,0 +1,7 @@ + +| +| " + " +| +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-27/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-27/input.xml new file mode 100644 index 000000000000..9c7e345df3fc --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-27/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-27/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-27/output.json new file mode 100644 index 000000000000..b12298cbd852 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-27/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 75, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 73, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 65, + "ctxt": 0 + }, + "data": "" + }, + { + "type": "Text", + "span": { + "start": 65, + "end": 66, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-27/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-27/output.stderr new file mode 100644 index 000000000000..d7e6dc7ff0ae --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-27/output.stderr @@ -0,0 +1,6 @@ + + x Nested comment + ,-[$DIR/tests/recovery/comments/bad-27/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-27/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-27/span.rust-debug new file mode 100644 index 000000000000..1b448b5c3dee --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-27/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-27/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-27/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-27/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-27/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-27/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-27/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-27/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-27/input.xml:3:5] + 3 | + : ^^^^^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-27/input.xml:3:5] + 3 | + : ^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-27/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-27/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-28/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-28/dom.rust-debug new file mode 100644 index 000000000000..a646d5ed2583 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-28/dom.rust-debug @@ -0,0 +1,7 @@ + +| +| " + " +| +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-28/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-28/input.xml new file mode 100644 index 000000000000..a85ee09fd02b --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-28/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-28/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-28/output.json new file mode 100644 index 000000000000..a13c92815024 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-28/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 76, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 74, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 66, + "ctxt": 0 + }, + "data": "" + }, + { + "type": "Text", + "span": { + "start": 66, + "end": 67, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-28/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-28/output.stderr new file mode 100644 index 000000000000..4996d74c4500 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-28/output.stderr @@ -0,0 +1,6 @@ + + x Nested comment + ,-[$DIR/tests/recovery/comments/bad-28/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-28/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-28/span.rust-debug new file mode 100644 index 000000000000..e6f68b020ac2 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-28/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-28/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-28/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-28/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-28/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-28/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-28/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-28/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-28/input.xml:3:5] + 3 | + : ^^^^^^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-28/input.xml:3:5] + 3 | + : ^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-28/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-28/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-29/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-29/dom.rust-debug new file mode 100644 index 000000000000..69572c9a57ca --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-29/dom.rust-debug @@ -0,0 +1,8 @@ + +| +| " + " +| diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-29/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-29/input.xml new file mode 100644 index 000000000000..25b32f35cf17 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-29/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-3/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-3/input.xml new file mode 100644 index 000000000000..a9530b2e8f8b --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-3/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-30/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-30/input.xml new file mode 100644 index 000000000000..ab1ad9e65c37 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-30/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-31/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-31/input.xml new file mode 100644 index 000000000000..4b9c05687d77 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-31/input.xml @@ -0,0 +1,5 @@ + + + +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-32/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-32/input.xml new file mode 100644 index 000000000000..f50eb8ca4111 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-32/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-32/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-32/output.json new file mode 100644 index 000000000000..8c7e04e7cf83 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-32/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 69, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 67, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 59, + "ctxt": 0 + }, + "data": "-", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 59, + "end": 60, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-32/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-32/output.stderr new file mode 100644 index 000000000000..4af7569912e4 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-32/output.stderr @@ -0,0 +1,6 @@ + + x Double hyper within comment + ,-[$DIR/tests/recovery/comments/bad-32/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-32/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-32/span.rust-debug new file mode 100644 index 000000000000..5ea3f27fb02e --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-32/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-32/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-32/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-32/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-32/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-32/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-32/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-32/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-32/input.xml:3:5] + 3 | + : ^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-32/input.xml:3:5] + 3 | + : ^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-32/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-32/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-33/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-33/dom.rust-debug new file mode 100644 index 000000000000..0fdcfe0b1731 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-33/dom.rust-debug @@ -0,0 +1,7 @@ + +| +| " + " +| +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-33/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-33/input.xml new file mode 100644 index 000000000000..b05a6506de8c --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-33/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-33/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-33/output.json new file mode 100644 index 000000000000..10de0789768a --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-33/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 70, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 68, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 60, + "ctxt": 0 + }, + "data": "--", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 60, + "end": 61, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-33/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-33/output.stderr new file mode 100644 index 000000000000..aa9b3fe93557 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-33/output.stderr @@ -0,0 +1,12 @@ + + x Double hyper within comment + ,-[$DIR/tests/recovery/comments/bad-33/input.xml:3:5] + 3 | + : ^ + `---- + + x Double hyper within comment + ,-[$DIR/tests/recovery/comments/bad-33/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-33/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-33/span.rust-debug new file mode 100644 index 000000000000..24525d258816 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-33/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-33/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-33/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-33/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-33/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-33/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-33/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-33/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-33/input.xml:3:5] + 3 | + : ^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-33/input.xml:3:5] + 3 | + : ^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-33/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-33/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-34/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-34/dom.rust-debug new file mode 100644 index 000000000000..a12bc039d757 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-34/dom.rust-debug @@ -0,0 +1,7 @@ + +| +| " + " +| +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-34/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-34/input.xml new file mode 100644 index 000000000000..42079fee0f67 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-34/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-34/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-34/output.json new file mode 100644 index 000000000000..811e06f3ea40 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-34/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 70, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 68, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 60, + "ctxt": 0 + }, + "data": " -", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 60, + "end": 61, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-34/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-34/output.stderr new file mode 100644 index 000000000000..b44d24d5d907 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-34/output.stderr @@ -0,0 +1,6 @@ + + x Double hyper within comment + ,-[$DIR/tests/recovery/comments/bad-34/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-34/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-34/span.rust-debug new file mode 100644 index 000000000000..4aea7b09f888 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-34/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-34/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-34/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-34/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-34/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-34/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-34/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-34/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-34/input.xml:3:5] + 3 | + : ^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-34/input.xml:3:5] + 3 | + : ^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-34/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-34/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-35/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-35/dom.rust-debug new file mode 100644 index 000000000000..2023b9e90d92 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-35/dom.rust-debug @@ -0,0 +1,7 @@ + +| +| " + " +| +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-35/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-35/input.xml new file mode 100644 index 000000000000..3914ac21afca --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-35/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-35/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-35/output.json new file mode 100644 index 000000000000..daeb40b209b2 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-35/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 70, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 68, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 60, + "ctxt": 0 + }, + "data": "a-", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 60, + "end": 61, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-35/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-35/output.stderr new file mode 100644 index 000000000000..8a1830d4a8e1 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-35/output.stderr @@ -0,0 +1,6 @@ + + x Double hyper within comment + ,-[$DIR/tests/recovery/comments/bad-35/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-35/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-35/span.rust-debug new file mode 100644 index 000000000000..bfeb997b8177 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-35/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-35/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-35/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-35/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-35/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-35/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-35/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-35/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-35/input.xml:3:5] + 3 | + : ^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-35/input.xml:3:5] + 3 | + : ^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-35/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-35/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-36/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-36/dom.rust-debug new file mode 100644 index 000000000000..b5dfd9d004f2 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-36/dom.rust-debug @@ -0,0 +1,7 @@ + +| +| " + " +| +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-36/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-36/input.xml new file mode 100644 index 000000000000..0df86933b711 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-36/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-36/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-36/output.json new file mode 100644 index 000000000000..296571c7b0d7 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-36/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 81, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 79, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 71, + "ctxt": 0 + }, + "data": " B+, B, or B-", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 71, + "end": 72, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-36/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-36/output.stderr new file mode 100644 index 000000000000..490b6af88569 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-36/output.stderr @@ -0,0 +1,6 @@ + + x Double hyper within comment + ,-[$DIR/tests/recovery/comments/bad-36/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-36/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-36/span.rust-debug new file mode 100644 index 000000000000..ef52c83cf0ba --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-36/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-36/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-36/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-36/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-36/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-36/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-36/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-36/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-36/input.xml:3:5] + 3 | + : ^^^^^^^^^^^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-36/input.xml:3:5] + 3 | + : ^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-36/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-36/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-37/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-37/dom.rust-debug new file mode 100644 index 000000000000..e4dd0f8b1169 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-37/dom.rust-debug @@ -0,0 +1,7 @@ + +| +| " + " +| +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-37/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-37/input.xml new file mode 100644 index 000000000000..edf190dd7b37 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-37/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-37/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-37/output.json new file mode 100644 index 000000000000..862c355b2d6f --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-37/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 66, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 64, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 56, + "ctxt": 0 + }, + "data": "", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 56, + "end": 57, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-37/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-37/output.stderr new file mode 100644 index 000000000000..00d16bd1aa98 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-37/output.stderr @@ -0,0 +1,6 @@ + + x Abrupt closing of empty comment + ,-[$DIR/tests/recovery/comments/bad-37/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-37/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-37/span.rust-debug new file mode 100644 index 000000000000..4bc942ecaa6f --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-37/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-37/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-37/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-37/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-37/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-37/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-37/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-37/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-37/input.xml:3:5] + 3 | + : ^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-37/input.xml:3:5] + 3 | + : ^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-37/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-37/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-38/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-38/dom.rust-debug new file mode 100644 index 000000000000..e4dd0f8b1169 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-38/dom.rust-debug @@ -0,0 +1,7 @@ + +| +| " + " +| +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-38/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-38/input.xml new file mode 100644 index 000000000000..1252f86e98b4 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-38/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-38/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-38/output.json new file mode 100644 index 000000000000..42aebbd0d3b4 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-38/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 67, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 65, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 57, + "ctxt": 0 + }, + "data": "", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 57, + "end": 58, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-38/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-38/output.stderr new file mode 100644 index 000000000000..46d387d420a4 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-38/output.stderr @@ -0,0 +1,6 @@ + + x Abrupt closing of empty comment + ,-[$DIR/tests/recovery/comments/bad-38/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-38/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-38/span.rust-debug new file mode 100644 index 000000000000..76fbfb3db16c --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-38/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-38/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-38/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-38/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-38/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-38/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-38/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-38/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-38/input.xml:3:5] + 3 | + : ^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-38/input.xml:3:5] + 3 | + : ^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-38/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-38/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-39/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-39/dom.rust-debug new file mode 100644 index 000000000000..0fdcfe0b1731 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-39/dom.rust-debug @@ -0,0 +1,7 @@ + +| +| " + " +| +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-39/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-39/input.xml new file mode 100644 index 000000000000..b05a6506de8c --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-39/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-39/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-39/output.json new file mode 100644 index 000000000000..10de0789768a --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-39/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 70, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 68, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 60, + "ctxt": 0 + }, + "data": "--", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 60, + "end": 61, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-39/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-39/output.stderr new file mode 100644 index 000000000000..a465ed588661 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-39/output.stderr @@ -0,0 +1,12 @@ + + x Double hyper within comment + ,-[$DIR/tests/recovery/comments/bad-39/input.xml:3:5] + 3 | + : ^ + `---- + + x Double hyper within comment + ,-[$DIR/tests/recovery/comments/bad-39/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-39/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-39/span.rust-debug new file mode 100644 index 000000000000..8d2b39f85afe --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-39/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-39/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-39/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-39/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-39/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-39/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-39/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-39/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-39/input.xml:3:5] + 3 | + : ^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-39/input.xml:3:5] + 3 | + : ^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-39/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-39/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-4/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-4/dom.rust-debug new file mode 100644 index 000000000000..e4dd0f8b1169 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-4/dom.rust-debug @@ -0,0 +1,7 @@ + +| +| " + " +| +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-4/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-4/input.xml new file mode 100644 index 000000000000..1252f86e98b4 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-4/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-4/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-4/output.json new file mode 100644 index 000000000000..42aebbd0d3b4 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-4/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 67, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 65, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 57, + "ctxt": 0 + }, + "data": "", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 57, + "end": 58, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-4/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-4/output.stderr new file mode 100644 index 000000000000..b01137b914a4 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-4/output.stderr @@ -0,0 +1,6 @@ + + x Abrupt closing of empty comment + ,-[$DIR/tests/recovery/comments/bad-4/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-4/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-4/span.rust-debug new file mode 100644 index 000000000000..a473ea3233a6 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-4/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-4/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-4/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-4/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-4/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-4/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-4/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-4/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-4/input.xml:3:5] + 3 | + : ^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-4/input.xml:3:5] + 3 | + : ^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-4/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-4/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-40/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-40/dom.rust-debug new file mode 100644 index 000000000000..f30c6a900d63 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-40/dom.rust-debug @@ -0,0 +1,62 @@ + +| +| " + " +| +| +| "Char* ']]>' " +| +| def="NT-Char" +| "Char" +| "*)) +']]>' +" +| +| "CDATA sections" +| " +" +| +| "| '<!DOCTYPE' +(" +| +| def="NT-Char" +| "Char" +| " - ('[' | ']'))+ +('[' +" +| +| def="NT-simpleDTD" +| "simpleDTD" +| "* +']')? '>'" +| " +" +| +| "doc type declaration" +| " +" +| +| id="NT-simpleDTD" +| +| "simpleDTD" +| " +" +| +| "'<!&como;' +(" +| +| def="NT-Char" +| "Char" +| "* - +(" +| +| def="NT-Char" +| "Char" +| "* '&comc;' " +| +| def="NT-Char" +| "Char" +| "*)) +'&comc;>'" +| "--> +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-40/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-40/input.xml new file mode 100644 index 000000000000..74d7590c9b59 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-40/input.xml @@ -0,0 +1,18 @@ + + + + Char* ']]>' Char*)) +']]>' +CDATA sections +| '<!DOCTYPE' +(Char - ('[' | ']'))+ +('[' +simpleDTD* +']')? '>' +doc type declaration +simpleDTD +'<!&como;' +(Char* - +(Char* '&comc;' Char*)) +'&comc;>'--> + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-40/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-40/output.json new file mode 100644 index 000000000000..909e943f7a22 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-40/output.json @@ -0,0 +1,541 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 526, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 41, + "end": 525, + "ctxt": 0 + }, + "tagName": "foo", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 72, + "ctxt": 0 + }, + "data": " def='NT-Char'", + "raw": "" + }, + { + "type": "Comment", + "span": { + "start": 72, + "end": 77, + "ctxt": 0 + }, + "data": "", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 77, + "end": 97, + "ctxt": 0 + }, + "data": "Char* ']]>' ", + "raw": "Char* ']]>' " + }, + { + "type": "Element", + "span": { + "start": 97, + "end": 124, + "ctxt": 0 + }, + "tagName": "nt", + "attributes": [ + { + "type": "Attribute", + "span": { + "start": 0, + "end": 0, + "ctxt": 0 + }, + "namespace": null, + "prefix": null, + "name": "def", + "rawName": "def", + "value": "NT-Char", + "rawValue": "'NT-Char'" + } + ], + "children": [ + { + "type": "Text", + "span": { + "start": 115, + "end": 119, + "ctxt": 0 + }, + "data": "Char", + "raw": "Char" + } + ] + }, + { + "type": "Text", + "span": { + "start": 124, + "end": 143, + "ctxt": 0 + }, + "data": "*))\n']]>'\n", + "raw": "*))\n']]>'\n" + }, + { + "type": "Element", + "span": { + "start": 143, + "end": 168, + "ctxt": 0 + }, + "tagName": "com", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 148, + "end": 162, + "ctxt": 0 + }, + "data": "CDATA sections", + "raw": "CDATA sections" + } + ] + }, + { + "type": "Text", + "span": { + "start": 168, + "end": 169, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + }, + { + "type": "Element", + "span": { + "start": 169, + "end": 298, + "ctxt": 0 + }, + "tagName": "rhs", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 174, + "end": 192, + "ctxt": 0 + }, + "data": "| '<!DOCTYPE'\n(", + "raw": "| '<!DOCTYPE'\n(" + }, + { + "type": "Element", + "span": { + "start": 192, + "end": 219, + "ctxt": 0 + }, + "tagName": "nt", + "attributes": [ + { + "type": "Attribute", + "span": { + "start": 0, + "end": 0, + "ctxt": 0 + }, + "namespace": null, + "prefix": null, + "name": "def", + "rawName": "def", + "value": "NT-Char", + "rawValue": "\"NT-Char\"" + } + ], + "children": [ + { + "type": "Text", + "span": { + "start": 210, + "end": 214, + "ctxt": 0 + }, + "data": "Char", + "raw": "Char" + } + ] + }, + { + "type": "Text", + "span": { + "start": 219, + "end": 241, + "ctxt": 0 + }, + "data": " - ('[' | ']'))+\n('['\n", + "raw": " - ('[' | ']'))+\n('['\n" + }, + { + "type": "Element", + "span": { + "start": 241, + "end": 278, + "ctxt": 0 + }, + "tagName": "nt", + "attributes": [ + { + "type": "Attribute", + "span": { + "start": 0, + "end": 0, + "ctxt": 0 + }, + "namespace": null, + "prefix": null, + "name": "def", + "rawName": "def", + "value": "NT-simpleDTD", + "rawValue": "\"NT-simpleDTD\"" + } + ], + "children": [ + { + "type": "Text", + "span": { + "start": 264, + "end": 273, + "ctxt": 0 + }, + "data": "simpleDTD", + "raw": "simpleDTD" + } + ] + }, + { + "type": "Text", + "span": { + "start": 278, + "end": 292, + "ctxt": 0 + }, + "data": "*\n']')? '>'", + "raw": "*\n']')? '>'" + } + ] + }, + { + "type": "Text", + "span": { + "start": 298, + "end": 299, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + }, + { + "type": "Element", + "span": { + "start": 299, + "end": 330, + "ctxt": 0 + }, + "tagName": "com", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 304, + "end": 324, + "ctxt": 0 + }, + "data": "doc type declaration", + "raw": "doc type declaration" + } + ] + }, + { + "type": "Text", + "span": { + "start": 330, + "end": 331, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + }, + { + "type": "Element", + "span": { + "start": 331, + "end": 519, + "ctxt": 0 + }, + "tagName": "prod", + "attributes": [ + { + "type": "Attribute", + "span": { + "start": 0, + "end": 0, + "ctxt": 0 + }, + "namespace": null, + "prefix": null, + "name": "id", + "rawName": "id", + "value": "NT-simpleDTD", + "rawValue": "\"NT-simpleDTD\"" + } + ], + "children": [ + { + "type": "Element", + "span": { + "start": 355, + "end": 375, + "ctxt": 0 + }, + "tagName": "lhs", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 360, + "end": 369, + "ctxt": 0 + }, + "data": "simpleDTD", + "raw": "simpleDTD" + } + ] + }, + { + "type": "Text", + "span": { + "start": 375, + "end": 376, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + }, + { + "type": "Element", + "span": { + "start": 376, + "end": 515, + "ctxt": 0 + }, + "tagName": "rhs", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 381, + "end": 396, + "ctxt": 0 + }, + "data": "'<!&como;'\n(", + "raw": "'<!&como;'\n(" + }, + { + "type": "Element", + "span": { + "start": 396, + "end": 423, + "ctxt": 0 + }, + "tagName": "nt", + "attributes": [ + { + "type": "Attribute", + "span": { + "start": 0, + "end": 0, + "ctxt": 0 + }, + "namespace": null, + "prefix": null, + "name": "def", + "rawName": "def", + "value": "NT-Char", + "rawValue": "'NT-Char'" + } + ], + "children": [ + { + "type": "Text", + "span": { + "start": 414, + "end": 418, + "ctxt": 0 + }, + "data": "Char", + "raw": "Char" + } + ] + }, + { + "type": "Text", + "span": { + "start": 423, + "end": 428, + "ctxt": 0 + }, + "data": "* -\n(", + "raw": "* -\n(" + }, + { + "type": "Element", + "span": { + "start": 428, + "end": 455, + "ctxt": 0 + }, + "tagName": "nt", + "attributes": [ + { + "type": "Attribute", + "span": { + "start": 0, + "end": 0, + "ctxt": 0 + }, + "namespace": null, + "prefix": null, + "name": "def", + "rawName": "def", + "value": "NT-Char", + "rawValue": "'NT-Char'" + } + ], + "children": [ + { + "type": "Text", + "span": { + "start": 446, + "end": 450, + "ctxt": 0 + }, + "data": "Char", + "raw": "Char" + } + ] + }, + { + "type": "Text", + "span": { + "start": 455, + "end": 466, + "ctxt": 0 + }, + "data": "* '&comc;' ", + "raw": "* '&comc;' " + }, + { + "type": "Element", + "span": { + "start": 466, + "end": 493, + "ctxt": 0 + }, + "tagName": "nt", + "attributes": [ + { + "type": "Attribute", + "span": { + "start": 0, + "end": 0, + "ctxt": 0 + }, + "namespace": null, + "prefix": null, + "name": "def", + "rawName": "def", + "value": "NT-Char", + "rawValue": "'NT-Char'" + } + ], + "children": [ + { + "type": "Text", + "span": { + "start": 484, + "end": 488, + "ctxt": 0 + }, + "data": "Char", + "raw": "Char" + } + ] + }, + { + "type": "Text", + "span": { + "start": 493, + "end": 509, + "ctxt": 0 + }, + "data": "*))\n'&comc;>'", + "raw": "*))\n'&comc;>'" + } + ] + }, + { + "type": "Text", + "span": { + "start": 515, + "end": 519, + "ctxt": 0 + }, + "data": "-->\n", + "raw": "-->\n" + } + ] + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-40/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-40/output.stderr new file mode 100644 index 000000000000..590b172c2c93 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-40/output.stderr @@ -0,0 +1,24 @@ + + x Abrupt closing of empty comment + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:4:5] + 4 | Char* ']]>' Char*)) + : ^ + `---- + + x Opening and ending tag mismatch + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:4:5] + 4 | Char* ']]>' Char*)) + : ^^^^^ + `---- + + x Opening and ending tag mismatch + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:5:1] + 5 | ']]>' + : ^^^^^^ + `---- + + x Opening and ending tag mismatch + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:18:1] + 18 | + : ^^^^^^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-40/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-40/span.rust-debug new file mode 100644 index 000000000000..f9ab235414ff --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-40/span.rust-debug @@ -0,0 +1,564 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | Char* ']]>' Char*)) + 5 | | ']]>' + 6 | | CDATA sections + 7 | | | '<!DOCTYPE' + 8 | | (Char - ('[' | ']'))+ + 9 | | ('[' + 10 | | simpleDTD* + 11 | | ']')? '>' + 12 | | doc type declaration + 13 | | simpleDTD + 14 | | '<!&como;' + 15 | | (Char* - + 16 | | (Char* '&comc;' Char*)) + 17 | | '&comc;>'--> + 18 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:3:1] + 3 | ,-> + 4 | | Char* ']]>' Char*)) + 5 | | ']]>' + 6 | | CDATA sections + 7 | | | '<!DOCTYPE' + 8 | | (Char - ('[' | ']'))+ + 9 | | ('[' + 10 | | simpleDTD* + 11 | | ']')? '>' + 12 | | doc type declaration + 13 | | simpleDTD + 14 | | '<!&como;' + 15 | | (Char* - + 16 | | (Char* '&comc;' Char*)) + 17 | | '&comc;>'--> + 18 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:3:1] + 3 | ,-> + 4 | | Char* ']]>' Char*)) + 5 | | ']]>' + 6 | | CDATA sections + 7 | | | '<!DOCTYPE' + 8 | | (Char - ('[' | ']'))+ + 9 | | ('[' + 10 | | simpleDTD* + 11 | | ']')? '>' + 12 | | doc type declaration + 13 | | simpleDTD + 14 | | '<!&como;' + 15 | | (Char* - + 16 | | (Char* '&comc;' Char*)) + 17 | | '&comc;>'--> + 18 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:3:1] + 3 | ,-> + 4 | `-> Char* ']]>' Char*)) + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:3:1] + 3 | ,-> + 4 | `-> Char* ']]>' Char*)) + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:4:5] + 4 | Char* ']]>' Char*)) + : ^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:4:5] + 4 | Char* ']]>' Char*)) + : ^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:4:5] + 4 | Char* ']]>' Char*)) + : ^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:4:5] + 4 | Char* ']]>' Char*)) + : ^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:4:5] + 4 | Char* ']]>' Char*)) + : ^^^^^^^^^^^^^^^^^^^^ + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:4:5] + 4 | Char* ']]>' Char*)) + : ^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:4:5] + 4 | Char* ']]>' Char*)) + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:4:5] + 4 | Char* ']]>' Char*)) + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Attribute + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:4:5] + 4 | Char* ']]>' Char*)) + : ^^^^ + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:4:5] + 4 | Char* ']]>' Char*)) + : ^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:4:5] + 4 | ,-> Char* ']]>' Char*)) + 5 | `-> ']]>' + 6 | CDATA sections + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:4:5] + 4 | ,-> Char* ']]>' Char*)) + 5 | `-> ']]>' + 6 | CDATA sections + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:6:1] + 6 | CDATA sections + : ^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:6:1] + 6 | CDATA sections + : ^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:6:1] + 6 | CDATA sections + : ^^^^^^^^^^^^^^ + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:6:1] + 6 | CDATA sections + : ^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:6:1] + 6 | CDATA sections + : ^ + 7 | | '<!DOCTYPE' + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:6:1] + 6 | CDATA sections + : ^ + 7 | | '<!DOCTYPE' + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:7:1] + 7 | ,-> | '<!DOCTYPE' + 8 | | (Char - ('[' | ']'))+ + 9 | | ('[' + 10 | | simpleDTD* + 11 | `-> ']')? '>' + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:7:1] + 7 | ,-> | '<!DOCTYPE' + 8 | | (Char - ('[' | ']'))+ + 9 | | ('[' + 10 | | simpleDTD* + 11 | `-> ']')? '>' + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:7:1] + 7 | ,-> | '<!DOCTYPE' + 8 | `-> (Char - ('[' | ']'))+ + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:7:1] + 7 | ,-> | '<!DOCTYPE' + 8 | `-> (Char - ('[' | ']'))+ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:8:1] + 8 | (Char - ('[' | ']'))+ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:8:1] + 8 | (Char - ('[' | ']'))+ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:8:1] + 8 | (Char - ('[' | ']'))+ + : ^^^^ + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:8:1] + 8 | (Char - ('[' | ']'))+ + : ^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:8:1] + 8 | ,-> (Char - ('[' | ']'))+ + 9 | `-> ('[' + 10 | simpleDTD* + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:8:1] + 8 | ,-> (Char - ('[' | ']'))+ + 9 | `-> ('[' + 10 | simpleDTD* + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:10:1] + 10 | simpleDTD* + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:10:1] + 10 | simpleDTD* + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:10:1] + 10 | simpleDTD* + : ^^^^^^^^^ + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:10:1] + 10 | simpleDTD* + : ^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:10:1] + 10 | ,-> simpleDTD* + 11 | `-> ']')? '>' + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:10:1] + 10 | ,-> simpleDTD* + 11 | `-> ']')? '>' + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:11:1] + 11 | ']')? '>' + : ^ + 12 | doc type declaration + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:11:1] + 11 | ']')? '>' + : ^ + 12 | doc type declaration + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:12:1] + 12 | doc type declaration + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:12:1] + 12 | doc type declaration + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:12:1] + 12 | doc type declaration + : ^^^^^^^^^^^^^^^^^^^^ + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:12:1] + 12 | doc type declaration + : ^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:12:1] + 12 | doc type declaration + : ^ + 13 | simpleDTD + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:12:1] + 12 | doc type declaration + : ^ + 13 | simpleDTD + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:13:1] + 13 | ,-> simpleDTD + 14 | | '<!&como;' + 15 | | (Char* - + 16 | | (Char* '&comc;' Char*)) + 17 | `-> '&comc;>'--> + 18 | + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:13:1] + 13 | ,-> simpleDTD + 14 | | '<!&como;' + 15 | | (Char* - + 16 | | (Char* '&comc;' Char*)) + 17 | `-> '&comc;>'--> + 18 | + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:13:1] + 13 | simpleDTD + : ^^^^^^^^^^^^^^^^^^^^ + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:13:1] + 13 | simpleDTD + : ^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:13:1] + 13 | simpleDTD + : ^^^^^^^^^ + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:13:1] + 13 | simpleDTD + : ^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:13:1] + 13 | simpleDTD + : ^ + 14 | '<!&como;' + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:13:1] + 13 | simpleDTD + : ^ + 14 | '<!&como;' + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:14:1] + 14 | ,-> '<!&como;' + 15 | | (Char* - + 16 | | (Char* '&comc;' Char*)) + 17 | `-> '&comc;>'--> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:14:1] + 14 | ,-> '<!&como;' + 15 | | (Char* - + 16 | | (Char* '&comc;' Char*)) + 17 | `-> '&comc;>'--> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:14:1] + 14 | ,-> '<!&como;' + 15 | `-> (Char* - + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:14:1] + 14 | ,-> '<!&como;' + 15 | `-> (Char* - + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:15:1] + 15 | (Char* - + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:15:1] + 15 | (Char* - + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:15:1] + 15 | (Char* - + : ^^^^ + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:15:1] + 15 | (Char* - + : ^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:15:1] + 15 | ,-> (Char* - + 16 | `-> (Char* '&comc;' Char*)) + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:15:1] + 15 | ,-> (Char* - + 16 | `-> (Char* '&comc;' Char*)) + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:16:1] + 16 | (Char* '&comc;' Char*)) + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:16:1] + 16 | (Char* '&comc;' Char*)) + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:16:1] + 16 | (Char* '&comc;' Char*)) + : ^^^^ + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:16:1] + 16 | (Char* '&comc;' Char*)) + : ^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:16:1] + 16 | (Char* '&comc;' Char*)) + : ^^^^^^^^^^^ + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:16:1] + 16 | (Char* '&comc;' Char*)) + : ^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:16:1] + 16 | (Char* '&comc;' Char*)) + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:16:1] + 16 | (Char* '&comc;' Char*)) + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:16:1] + 16 | (Char* '&comc;' Char*)) + : ^^^^ + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:16:1] + 16 | (Char* '&comc;' Char*)) + : ^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:16:1] + 16 | ,-> (Char* '&comc;' Char*)) + 17 | `-> '&comc;>'--> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:16:1] + 16 | ,-> (Char* '&comc;' Char*)) + 17 | `-> '&comc;>'--> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:17:1] + 17 | '&comc;>'--> + : ^^^^ + 18 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-40/input.xml:17:1] + 17 | '&comc;>'--> + : ^^^^ + 18 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-5/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-5/dom.rust-debug new file mode 100644 index 000000000000..a21cadb548cc --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-5/dom.rust-debug @@ -0,0 +1,8 @@ + +| +| " + " +| diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-5/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-5/input.xml new file mode 100644 index 000000000000..2436c1c1d59c --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-5/input.xml @@ -0,0 +1,5 @@ + + + +| " +" diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-6/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-6/input.xml new file mode 100644 index 000000000000..edf190dd7b37 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-6/input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-6/output.json b/crates/swc_xml_parser/tests/recovery/comments/bad-6/output.json new file mode 100644 index 000000000000..862c355b2d6f --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-6/output.json @@ -0,0 +1,62 @@ +{ + "type": "Document", + "span": { + "start": 1, + "end": 66, + "ctxt": 0 + }, + "children": [ + { + "type": "ProcessingInstruction", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "target": "xml", + "data": "version=\"1.0\" encoding=\"UTF-8\"" + }, + { + "type": "Element", + "span": { + "start": 40, + "end": 64, + "ctxt": 0 + }, + "tagName": "root", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 46, + "end": 51, + "ctxt": 0 + }, + "data": "\n ", + "raw": "\n " + }, + { + "type": "Comment", + "span": { + "start": 51, + "end": 56, + "ctxt": 0 + }, + "data": "", + "raw": "" + }, + { + "type": "Text", + "span": { + "start": 56, + "end": 57, + "ctxt": 0 + }, + "data": "\n", + "raw": "\n" + } + ] + } + ] +} diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-6/output.stderr b/crates/swc_xml_parser/tests/recovery/comments/bad-6/output.stderr new file mode 100644 index 000000000000..a66f52a4e751 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-6/output.stderr @@ -0,0 +1,6 @@ + + x Abrupt closing of empty comment + ,-[$DIR/tests/recovery/comments/bad-6/input.xml:3:5] + 3 | + : ^ + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-6/span.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-6/span.rust-debug new file mode 100644 index 000000000000..367238140fcc --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-6/span.rust-debug @@ -0,0 +1,73 @@ + + x Document + ,-[$DIR/tests/recovery/comments/bad-6/input.xml:1:1] + 1 | ,-> + 2 | | + 3 | | + 4 | | + 5 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-6/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ProcessingInstruction + ,-[$DIR/tests/recovery/comments/bad-6/input.xml:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-6/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Element + ,-[$DIR/tests/recovery/comments/bad-6/input.xml:2:1] + 2 | ,-> + 3 | | + 4 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-6/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-6/input.xml:2:1] + 2 | ,-> + 3 | `-> + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-6/input.xml:3:5] + 3 | + : ^^^^^ + `---- + + x Comment + ,-[$DIR/tests/recovery/comments/bad-6/input.xml:3:5] + 3 | + : ^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/comments/bad-6/input.xml:3:5] + 3 | + : ^ + 4 | + `---- + + x Text + ,-[$DIR/tests/recovery/comments/bad-6/input.xml:3:5] + 3 | + : ^ + 4 | + `---- diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-7/dom.rust-debug b/crates/swc_xml_parser/tests/recovery/comments/bad-7/dom.rust-debug new file mode 100644 index 000000000000..7d4db170c300 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-7/dom.rust-debug @@ -0,0 +1,8 @@ + +| +| " + " +| diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-7/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-7/input.xml new file mode 100644 index 000000000000..3936d7a16184 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-7/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-8/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-8/input.xml new file mode 100644 index 000000000000..481726e4fc51 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-8/input.xml @@ -0,0 +1,5 @@ + + + diff --git a/crates/swc_xml_parser/tests/recovery/comments/bad-9/input.xml b/crates/swc_xml_parser/tests/recovery/comments/bad-9/input.xml new file mode 100644 index 000000000000..d0a4e95c0b69 --- /dev/null +++ b/crates/swc_xml_parser/tests/recovery/comments/bad-9/input.xml @@ -0,0 +1,5 @@ + + +