Skip to content

Commit 44263ce

Browse files
feat(html): read and print XML through a tokenizer and DTD of its own
Parse `xml: true` with a dedicated XML tokenizer instead of the WHATWG one, which ended a DOCTYPE at its first `>`: internal subsets now read whole, their general entities (markup included, bounded against expansion bombs) and ATTLIST defaults apply, attribute values normalize per §3.3.3, and misnested end tags recover. The printer writes XML back rather than HTML. Hold it to the W3C XML Conformance Test Suite (new submodule and a `parser (xml)` CI leg), and add `tooling/compare-xml-tools.js` with its invariants gated in the `invariants` job. Claude-Session: https://claude.ai/code/session_01WzCD9CDRFzG1j2yQARWzLp Co-authored-by: Alexander Akait <[email protected]>
1 parent 4949a92 commit 44263ce

21 files changed

Lines changed: 3972 additions & 48 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": minor
3+
---
4+
5+
Add an `xml` mode to `html.syntax` that parses and prints XML, DTD entities included.

‎.github/dependabot.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ updates:
3131
- "/tooling/comparison/css-tool-comparison"
3232
- "/tooling/comparison/html-tool-comparison"
3333
- "/tooling/comparison/js-tool-comparison"
34+
- "/tooling/comparison/xml-tool-comparison"
3435
schedule:
3536
interval: "monthly"
3637
open-pull-requests-limit: 3

‎.github/workflows/test.yml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ jobs:
109109
path: node_modules/.cache/js-tool-comparison
110110
key: comparison-corpus-js-${{ runner.os }}-${{ hashFiles('tooling/comparison/js-tool-comparison/package.json', 'tooling/comparison/js-tool-comparison/package-lock.json') }}
111111

112+
# Its own key for the same reason: nothing else reads the XML corpus.
113+
- name: Cache the XML comparison corpus
114+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
115+
with:
116+
path: node_modules/.cache/xml-tool-comparison
117+
key: comparison-corpus-xml-${{ runner.os }}-${{ hashFiles('tooling/comparison/xml-tool-comparison/package.json', 'tooling/comparison/xml-tool-comparison/package-lock.json') }}
118+
112119
# Fatal here, unlike the equivalence job: that one reads whichever
113120
# fixtures are there, and this one is the check that the whole corpus
114121
# stays clean. Retried rather than tolerated, a registry blip being the
@@ -126,6 +133,9 @@ jobs:
126133
- name: Install the JavaScript comparison corpus
127134
run: node tooling/retry.js yarn benchmark:js-tools:setup
128135

136+
- name: Install the XML comparison corpus
137+
run: node tooling/retry.js yarn benchmark:xml-tools:setup
138+
129139
# `--require-corpus`: without it a sweep that lost a fixture reports the
130140
# findings of the ones it kept and passes, which is coverage lost with
131141
# nothing to read it off.
@@ -144,6 +154,10 @@ jobs:
144154
if: ${{ !cancelled() }}
145155
run: yarn test:invariants:js --require-corpus
146156

157+
- name: XML parser and printer invariants
158+
if: ${{ !cancelled() }}
159+
run: yarn test:invariants:xml --require-corpus
160+
147161
validate-legacy-node:
148162
runs-on: ubuntu-latest
149163
steps:
@@ -315,6 +329,12 @@ jobs:
315329
- language: minify-fuzz
316330
submodules: test/external/terser
317331
script: test:minify-fuzz
332+
# The W3C XML Conformance Test Suite: every document is read back in
333+
# canonical form and printed, which is small enough to run covered.
334+
- language: xml
335+
submodules: test/external/xml-conformance-suite
336+
script: cover:xmlconf
337+
flags: xmlconf
318338
runs-on: ubuntu-latest
319339
# Bounded: the js leg allows ten minutes per area per mode, so a stall
320340
# would otherwise hold a runner for the 6h default.

‎.gitmodules‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@
1919
[submodule "test/external/oxc"]
2020
path = test/external/oxc
2121
url = https://github.com/oxc-project/oxc
22+
[submodule "test/external/xml-conformance-suite"]
23+
path = test/external/xml-conformance-suite
24+
url = https://github.com/lddubeau/xml-conformance-suite.git

‎.prettierignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ test/external/wpt/**
2626
test/external/terser/**
2727
test/external/swc/**
2828
test/external/oxc/**
29+
test/external/xml-conformance-suite/**
2930

3031
# Ignore some folders
3132
benchmark/

‎codecov.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ coverage:
1818
- html5lib
1919
- test262
2020
- minify-corpora
21+
- xmlconf
2122
target: auto
2223
patch:
2324
default:
@@ -42,6 +43,7 @@ ignore:
4243
- "tooling/compare-css-tools.js"
4344
- "tooling/compare-html-tools.js"
4445
- "tooling/compare-js-tools.js"
46+
- "tooling/compare-xml-tools.js"
4547
# TODO in the next major release: remove
4648
- "lib/template/ChunkTemplate.js"
4749
- "lib/template/MainTemplate.js"

‎cspell.json‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"astring",
2323
"asyncloader",
2424
"atlaskit",
25+
"ATTLIST",
2526
"autocapitalize",
2627
"autocrlf",
2728
"autospace",
@@ -201,6 +202,7 @@
201202
"imagesrcset",
202203
"importmap",
203204
"informations",
205+
"inkscape",
204206
"inlines",
205207
"inputmode",
206208
"installurl",
@@ -235,6 +237,7 @@
235237
"layoutimage",
236238
"lcov",
237239
"lcovonly",
240+
"lddubeau",
238241
"libuv",
239242
"lightgoldenrodyellow",
240243
"lightningcss",
@@ -293,12 +296,16 @@
293296
"mylibrary",
294297
"mynamespace",
295298
"mypaint",
299+
"Nachrichten",
300+
"namedview",
296301
"Natsu",
297302
"navigations",
298303
"nesw",
299304
"Neue",
300305
"Nitin",
301306
"nmodule",
307+
"NMTOKEN",
308+
"NMTOKENS",
302309
"nocheck",
303310
"noembed",
304311
"nohref",
@@ -323,8 +330,11 @@
323330
"onbeforeload",
324331
"onconnect",
325332
"oneline",
333+
"onopentag",
334+
"ontext",
326335
"opencollective",
327336
"opensource",
337+
"opentag",
328338
"optimizelegibility",
329339
"optimizespeed",
330340
"opuuus",
@@ -333,6 +343,7 @@
333343
"overridables",
334344
"ovflowd",
335345
"packument",
346+
"pagecolor",
336347
"parallelism",
337348
"parseargs",
338349
"passthrough",
@@ -408,6 +419,7 @@
408419
"returnfalse",
409420
"revparse",
410421
"rgba",
422+
"rgrove",
411423
"rimraf",
412424
"Rivest",
413425
"rotatex",
@@ -450,6 +462,7 @@
450462
"smol",
451463
"snapshotting",
452464
"snitin",
465+
"sodipodi",
453466
"sokra",
454467
"somepackage",
455468
"somepath",
@@ -517,6 +530,7 @@
517530
"truespeed",
518531
"Tshs",
519532
"turbofan",
533+
"txml",
520534
"typebox",
521535
"typechecker",
522536
"typeof",
@@ -578,6 +592,8 @@
578592
"Xiao",
579593
"xiaoxiaojx",
580594
"xlink",
595+
"Xlint",
596+
"xmlconf",
581597
"Xmodule",
582598
"xrrggbb",
583599
"xxhash",
@@ -620,6 +636,7 @@
620636
"test/external/terser/**",
621637
"test/external/swc/**",
622638
"test/external/oxc/**",
639+
"test/external/xml-conformance-suite/**",
623640
"**/*.svg",
624641
"*.log",
625642
"**/*.wasm",

‎eslint.config.mjs‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export default defineConfig([
7575
"test/external/terser/**",
7676
"test/external/swc/**",
7777
"test/external/oxc/**",
78+
"test/external/xml-conformance-suite/**/*.*",
7879

7980
// Ignore some folders
8081
"benchmark",
@@ -374,7 +375,8 @@ export default defineConfig([
374375
"tooling/compare-css-tools.js",
375376
"tooling/compare-html-tools.js",
376377
"tooling/compare-js-tools.js",
377-
"tooling/compare-tools-harness.js"
378+
"tooling/compare-tools-harness.js",
379+
"tooling/compare-xml-tools.js"
378380
],
379381
rules: {
380382
"n/no-unsupported-features/node-builtins": "off"
@@ -404,9 +406,13 @@ export default defineConfig([
404406
},
405407
{
406408
// `color-name` is ESM, so the CSS data generator reaches its table through a
407-
// dynamic import rather than a `require` no jest `vm` supports.
408-
// `html-minifier-next` is ESM only and is imported the same way.
409-
files: ["tooling/generate-css-data.js", "tooling/compare-html-tools.js"],
409+
// dynamic import rather than a `require` no jest `vm` supports; the HTML and
410+
// XML comparisons import their ESM-only tools the same way.
411+
files: [
412+
"tooling/generate-css-data.js",
413+
"tooling/compare-html-tools.js",
414+
"tooling/compare-xml-tools.js"
415+
],
410416
rules: {
411417
"n/no-unsupported-features/es-syntax": [
412418
"error",

0 commit comments

Comments
 (0)