-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(xml/parser): Fix parsing of legacy document types (#6555)
- Loading branch information
1 parent
a9cccb0
commit cdf0d8a
Showing
57 changed files
with
1,876 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
crates/swc_xml_parser/tests/fixture/document_type/internal_subset-1/dom.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
| <!DOCTYPE svg> | ||
| <root> | ||
| "test" |
5 changes: 5 additions & 0 deletions
5
crates/swc_xml_parser/tests/fixture/document_type/internal_subset-1/input.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!DOCTYPE svg [ | ||
<!ENTITY Pub-Status "This is a pre-release of the | ||
specification."> | ||
]> | ||
<root>test</root> |
44 changes: 44 additions & 0 deletions
44
crates/swc_xml_parser/tests/fixture/document_type/internal_subset-1/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"type": "Document", | ||
"span": { | ||
"start": 1, | ||
"end": 112, | ||
"ctxt": 0 | ||
}, | ||
"children": [ | ||
{ | ||
"type": "DocumentType", | ||
"span": { | ||
"start": 1, | ||
"end": 94, | ||
"ctxt": 0 | ||
}, | ||
"name": "svg", | ||
"publicId": null, | ||
"systemId": null, | ||
"raw": "<!DOCTYPE svg [\n <!ENTITY Pub-Status \"This is a pre-release of the\nspecification.\">\n]>" | ||
}, | ||
{ | ||
"type": "Element", | ||
"span": { | ||
"start": 95, | ||
"end": 112, | ||
"ctxt": 0 | ||
}, | ||
"tagName": "root", | ||
"attributes": [], | ||
"children": [ | ||
{ | ||
"type": "Text", | ||
"span": { | ||
"start": 101, | ||
"end": 105, | ||
"ctxt": 0 | ||
}, | ||
"data": "test", | ||
"raw": "test" | ||
} | ||
] | ||
} | ||
] | ||
} |
55 changes: 55 additions & 0 deletions
55
crates/swc_xml_parser/tests/fixture/document_type/internal_subset-1/span.swc-stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
x Document | ||
,-[$DIR/tests/fixture/document_type/internal_subset-1/input.xml:1:1] | ||
1 | ,-> <!DOCTYPE svg [ | ||
2 | | <!ENTITY Pub-Status "This is a pre-release of the | ||
3 | | specification."> | ||
4 | | ]> | ||
5 | `-> <root>test</root> | ||
`---- | ||
|
||
x Child | ||
,-[$DIR/tests/fixture/document_type/internal_subset-1/input.xml:1:1] | ||
1 | ,-> <!DOCTYPE svg [ | ||
2 | | <!ENTITY Pub-Status "This is a pre-release of the | ||
3 | | specification."> | ||
4 | `-> ]> | ||
5 | <root>test</root> | ||
`---- | ||
|
||
x DocumentType | ||
,-[$DIR/tests/fixture/document_type/internal_subset-1/input.xml:1:1] | ||
1 | ,-> <!DOCTYPE svg [ | ||
2 | | <!ENTITY Pub-Status "This is a pre-release of the | ||
3 | | specification."> | ||
4 | `-> ]> | ||
5 | <root>test</root> | ||
`---- | ||
|
||
x Child | ||
,-[$DIR/tests/fixture/document_type/internal_subset-1/input.xml:4:1] | ||
4 | ]> | ||
5 | <root>test</root> | ||
: ^^^^^^^^^^^^^^^^^ | ||
`---- | ||
|
||
x Element | ||
,-[$DIR/tests/fixture/document_type/internal_subset-1/input.xml:4:1] | ||
4 | ]> | ||
5 | <root>test</root> | ||
: ^^^^^^^^^^^^^^^^^ | ||
`---- | ||
|
||
x Child | ||
,-[$DIR/tests/fixture/document_type/internal_subset-1/input.xml:4:1] | ||
4 | ]> | ||
5 | <root>test</root> | ||
: ^^^^ | ||
`---- | ||
|
||
x Text | ||
,-[$DIR/tests/fixture/document_type/internal_subset-1/input.xml:4:1] | ||
4 | ]> | ||
5 | <root>test</root> | ||
: ^^^^ | ||
`---- |
3 changes: 3 additions & 0 deletions
3
crates/swc_xml_parser/tests/fixture/document_type/internal_subset-2/dom.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
| <!DOCTYPE svg> | ||
| <root> | ||
| "test" |
4 changes: 4 additions & 0 deletions
4
crates/swc_xml_parser/tests/fixture/document_type/internal_subset-2/input.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!DOCTYPE svg [ | ||
<!ENTITY open-hatch SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml"> | ||
]> | ||
<root>test</root> |
44 changes: 44 additions & 0 deletions
44
crates/swc_xml_parser/tests/fixture/document_type/internal_subset-2/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"type": "Document", | ||
"span": { | ||
"start": 1, | ||
"end": 127, | ||
"ctxt": 0 | ||
}, | ||
"children": [ | ||
{ | ||
"type": "DocumentType", | ||
"span": { | ||
"start": 1, | ||
"end": 109, | ||
"ctxt": 0 | ||
}, | ||
"name": "svg", | ||
"publicId": null, | ||
"systemId": null, | ||
"raw": "<!DOCTYPE svg [\n <!ENTITY open-hatch SYSTEM \"http://www.textuality.com/boilerplate/OpenHatch.xml\">\n]>" | ||
}, | ||
{ | ||
"type": "Element", | ||
"span": { | ||
"start": 110, | ||
"end": 127, | ||
"ctxt": 0 | ||
}, | ||
"tagName": "root", | ||
"attributes": [], | ||
"children": [ | ||
{ | ||
"type": "Text", | ||
"span": { | ||
"start": 116, | ||
"end": 120, | ||
"ctxt": 0 | ||
}, | ||
"data": "test", | ||
"raw": "test" | ||
} | ||
] | ||
} | ||
] | ||
} |
52 changes: 52 additions & 0 deletions
52
crates/swc_xml_parser/tests/fixture/document_type/internal_subset-2/span.swc-stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
x Document | ||
,-[$DIR/tests/fixture/document_type/internal_subset-2/input.xml:1:1] | ||
1 | ,-> <!DOCTYPE svg [ | ||
2 | | <!ENTITY open-hatch SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml"> | ||
3 | | ]> | ||
4 | `-> <root>test</root> | ||
`---- | ||
|
||
x Child | ||
,-[$DIR/tests/fixture/document_type/internal_subset-2/input.xml:1:1] | ||
1 | ,-> <!DOCTYPE svg [ | ||
2 | | <!ENTITY open-hatch SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml"> | ||
3 | `-> ]> | ||
4 | <root>test</root> | ||
`---- | ||
|
||
x DocumentType | ||
,-[$DIR/tests/fixture/document_type/internal_subset-2/input.xml:1:1] | ||
1 | ,-> <!DOCTYPE svg [ | ||
2 | | <!ENTITY open-hatch SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml"> | ||
3 | `-> ]> | ||
4 | <root>test</root> | ||
`---- | ||
|
||
x Child | ||
,-[$DIR/tests/fixture/document_type/internal_subset-2/input.xml:3:1] | ||
3 | ]> | ||
4 | <root>test</root> | ||
: ^^^^^^^^^^^^^^^^^ | ||
`---- | ||
|
||
x Element | ||
,-[$DIR/tests/fixture/document_type/internal_subset-2/input.xml:3:1] | ||
3 | ]> | ||
4 | <root>test</root> | ||
: ^^^^^^^^^^^^^^^^^ | ||
`---- | ||
|
||
x Child | ||
,-[$DIR/tests/fixture/document_type/internal_subset-2/input.xml:3:1] | ||
3 | ]> | ||
4 | <root>test</root> | ||
: ^^^^ | ||
`---- | ||
|
||
x Text | ||
,-[$DIR/tests/fixture/document_type/internal_subset-2/input.xml:3:1] | ||
3 | ]> | ||
4 | <root>test</root> | ||
: ^^^^ | ||
`---- |
3 changes: 3 additions & 0 deletions
3
crates/swc_xml_parser/tests/fixture/document_type/internal_subset-3/dom.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
| <!DOCTYPE svg> | ||
| <root> | ||
| "test" |
6 changes: 6 additions & 0 deletions
6
crates/swc_xml_parser/tests/fixture/document_type/internal_subset-3/input.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!DOCTYPE svg [ | ||
<!ENTITY open-hatch | ||
PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN" | ||
"http://www.textuality.com/boilerplate/OpenHatch.xml"> | ||
]> | ||
<root>test</root> |
44 changes: 44 additions & 0 deletions
44
crates/swc_xml_parser/tests/fixture/document_type/internal_subset-3/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"type": "Document", | ||
"span": { | ||
"start": 1, | ||
"end": 205, | ||
"ctxt": 0 | ||
}, | ||
"children": [ | ||
{ | ||
"type": "DocumentType", | ||
"span": { | ||
"start": 1, | ||
"end": 187, | ||
"ctxt": 0 | ||
}, | ||
"name": "svg", | ||
"publicId": null, | ||
"systemId": null, | ||
"raw": "<!DOCTYPE svg [\n <!ENTITY open-hatch\n PUBLIC \"-//Textuality//TEXT Standard open-hatch boilerplate//EN\"\n \"http://www.textuality.com/boilerplate/OpenHatch.xml\">\n]>" | ||
}, | ||
{ | ||
"type": "Element", | ||
"span": { | ||
"start": 188, | ||
"end": 205, | ||
"ctxt": 0 | ||
}, | ||
"tagName": "root", | ||
"attributes": [], | ||
"children": [ | ||
{ | ||
"type": "Text", | ||
"span": { | ||
"start": 194, | ||
"end": 198, | ||
"ctxt": 0 | ||
}, | ||
"data": "test", | ||
"raw": "test" | ||
} | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.
cdf0d8a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
es/full/bugs-1
347600
ns/iter (± 21107
)368141
ns/iter (± 28973
)0.94
es/full/minify/libraries/antd
2036833240
ns/iter (± 65299279
)2127516739
ns/iter (± 48051678
)0.96
es/full/minify/libraries/d3
449921640
ns/iter (± 15545822
)473217805
ns/iter (± 14215411
)0.95
es/full/minify/libraries/echarts
1747869817
ns/iter (± 284198529
)1855852465
ns/iter (± 57373701
)0.94
es/full/minify/libraries/jquery
114051503
ns/iter (± 2348462
)119863093
ns/iter (± 13610713
)0.95
es/full/minify/libraries/lodash
131359407
ns/iter (± 5068345
)134541593
ns/iter (± 6967645
)0.98
es/full/minify/libraries/moment
66839836
ns/iter (± 2236533
)71337634
ns/iter (± 4323384
)0.94
es/full/minify/libraries/react
22065996
ns/iter (± 609807
)23052592
ns/iter (± 792122
)0.96
es/full/minify/libraries/terser
342266503
ns/iter (± 15979735
)483160127
ns/iter (± 106913714
)0.71
es/full/minify/libraries/three
625347510
ns/iter (± 13892819
)706939080
ns/iter (± 35525999
)0.88
es/full/minify/libraries/typescript
3659254464
ns/iter (± 77550761
)3973497652
ns/iter (± 119259385
)0.92
es/full/minify/libraries/victory
909940842
ns/iter (± 27053033
)957823876
ns/iter (± 45827666
)0.95
es/full/minify/libraries/vue
172808513
ns/iter (± 13676562
)172554248
ns/iter (± 12135151
)1.00
es/full/codegen/es3
34457
ns/iter (± 2655
)35294
ns/iter (± 4214
)0.98
es/full/codegen/es5
34829
ns/iter (± 1764
)34979
ns/iter (± 2704
)1.00
es/full/codegen/es2015
34404
ns/iter (± 1268
)35621
ns/iter (± 3738
)0.97
es/full/codegen/es2016
35214
ns/iter (± 927
)35248
ns/iter (± 3078
)1.00
es/full/codegen/es2017
34752
ns/iter (± 713
)35701
ns/iter (± 3230
)0.97
es/full/codegen/es2018
34071
ns/iter (± 950
)41745
ns/iter (± 6015
)0.82
es/full/codegen/es2019
34559
ns/iter (± 1412
)44094
ns/iter (± 6960
)0.78
es/full/codegen/es2020
34200
ns/iter (± 1638
)42595
ns/iter (± 7198
)0.80
es/full/all/es3
206436493
ns/iter (± 28503818
)266040720
ns/iter (± 36387557
)0.78
es/full/all/es5
209892739
ns/iter (± 18569666
)210921843
ns/iter (± 27949437
)1.00
es/full/all/es2015
152457874
ns/iter (± 17148838
)163885422
ns/iter (± 10517983
)0.93
es/full/all/es2016
155336471
ns/iter (± 23154947
)203425543
ns/iter (± 28237050
)0.76
es/full/all/es2017
156618860
ns/iter (± 16557551
)161988108
ns/iter (± 15138523
)0.97
es/full/all/es2018
148978570
ns/iter (± 14036603
)175256956
ns/iter (± 20480053
)0.85
es/full/all/es2019
156612369
ns/iter (± 17188799
)177737811
ns/iter (± 21527209
)0.88
es/full/all/es2020
150456177
ns/iter (± 14219881
)170617122
ns/iter (± 15733403
)0.88
es/full/parser
741042
ns/iter (± 38352
)912946
ns/iter (± 127217
)0.81
es/full/base/fixer
26725
ns/iter (± 1304
)31780
ns/iter (± 4400
)0.84
es/full/base/resolver_and_hygiene
93473
ns/iter (± 5180
)100604
ns/iter (± 11805
)0.93
serialization of ast node
211
ns/iter (± 8
)229
ns/iter (± 42
)0.92
serialization of serde
222
ns/iter (± 5
)222
ns/iter (± 18
)1
This comment was automatically generated by workflow using github-action-benchmark.