Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove length restriction from JSX entities, and ignore `Object.proto…
…type` (#14327) * Allow any length in unicode CP jsx entities * Add failing test * Don't access entities from Object.prototype * Add `�_0;` test * Fix `�` parsing
- Loading branch information
1 parent
5cf3118
commit 4bb9b89
Showing
11 changed files
with
272 additions
and
35 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
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
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
7 changes: 7 additions & 0 deletions
7
packages/babel-parser/test/fixtures/jsx/html-entities/code-point/input.js
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,7 @@ | ||
<a> | ||
Ӓ | ||
઼ | ||
Ӓ | ||
઼ | ||
� | ||
</a> |
52 changes: 52 additions & 0 deletions
52
packages/babel-parser/test/fixtures/jsx/html-entities/code-point/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,52 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":112,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":4,"index":112}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":112,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":4,"index":112}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":112,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":4,"index":112}}, | ||
"expression": { | ||
"type": "JSXElement", | ||
"start":0,"end":112,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":4,"index":112}}, | ||
"openingElement": { | ||
"type": "JSXOpeningElement", | ||
"start":0,"end":3,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":3,"index":3}}, | ||
"name": { | ||
"type": "JSXIdentifier", | ||
"start":1,"end":2,"loc":{"start":{"line":1,"column":1,"index":1},"end":{"line":1,"column":2,"index":2}}, | ||
"name": "a" | ||
}, | ||
"attributes": [], | ||
"selfClosing": false | ||
}, | ||
"closingElement": { | ||
"type": "JSXClosingElement", | ||
"start":108,"end":112,"loc":{"start":{"line":7,"column":0,"index":108},"end":{"line":7,"column":4,"index":112}}, | ||
"name": { | ||
"type": "JSXIdentifier", | ||
"start":110,"end":111,"loc":{"start":{"line":7,"column":2,"index":110},"end":{"line":7,"column":3,"index":111}}, | ||
"name": "a" | ||
} | ||
}, | ||
"children": [ | ||
{ | ||
"type": "JSXText", | ||
"start":3,"end":108,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":7,"column":0,"index":108}}, | ||
"extra": { | ||
"rawValue": "\n Ӓ\n ઼\n Ӓ\n ઼\n \u0000\n", | ||
"raw": "\n Ӓ\n ઼\n Ӓ\n ઼\n �\n" | ||
}, | ||
"value": "\n Ӓ\n ઼\n Ӓ\n ઼\n \u0000\n" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/jsx/html-entities/html4/input.js
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 @@ | ||
<a>&</a> |
52 changes: 52 additions & 0 deletions
52
packages/babel-parser/test/fixtures/jsx/html-entities/html4/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,52 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":12,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":12,"index":12}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":12,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":12,"index":12}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":12,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":12,"index":12}}, | ||
"expression": { | ||
"type": "JSXElement", | ||
"start":0,"end":12,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":12,"index":12}}, | ||
"openingElement": { | ||
"type": "JSXOpeningElement", | ||
"start":0,"end":3,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":3,"index":3}}, | ||
"name": { | ||
"type": "JSXIdentifier", | ||
"start":1,"end":2,"loc":{"start":{"line":1,"column":1,"index":1},"end":{"line":1,"column":2,"index":2}}, | ||
"name": "a" | ||
}, | ||
"attributes": [], | ||
"selfClosing": false | ||
}, | ||
"closingElement": { | ||
"type": "JSXClosingElement", | ||
"start":8,"end":12,"loc":{"start":{"line":1,"column":8,"index":8},"end":{"line":1,"column":12,"index":12}}, | ||
"name": { | ||
"type": "JSXIdentifier", | ||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":11,"index":11}}, | ||
"name": "a" | ||
} | ||
}, | ||
"children": [ | ||
{ | ||
"type": "JSXText", | ||
"start":3,"end":8,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":1,"column":8,"index":8}}, | ||
"extra": { | ||
"rawValue": "&", | ||
"raw": "&" | ||
}, | ||
"value": "&" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/babel-parser/test/fixtures/jsx/html-entities/invalid/input.js
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,7 @@ | ||
<a> | ||
& | ||
&a; | ||
& ; | ||
&xamp; | ||
�_0; | ||
</a> |
52 changes: 52 additions & 0 deletions
52
packages/babel-parser/test/fixtures/jsx/html-entities/invalid/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,52 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":61,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":4,"index":61}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":61,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":4,"index":61}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":61,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":4,"index":61}}, | ||
"expression": { | ||
"type": "JSXElement", | ||
"start":0,"end":61,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":4,"index":61}}, | ||
"openingElement": { | ||
"type": "JSXOpeningElement", | ||
"start":0,"end":3,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":3,"index":3}}, | ||
"name": { | ||
"type": "JSXIdentifier", | ||
"start":1,"end":2,"loc":{"start":{"line":1,"column":1,"index":1},"end":{"line":1,"column":2,"index":2}}, | ||
"name": "a" | ||
}, | ||
"attributes": [], | ||
"selfClosing": false | ||
}, | ||
"closingElement": { | ||
"type": "JSXClosingElement", | ||
"start":57,"end":61,"loc":{"start":{"line":7,"column":0,"index":57},"end":{"line":7,"column":4,"index":61}}, | ||
"name": { | ||
"type": "JSXIdentifier", | ||
"start":59,"end":60,"loc":{"start":{"line":7,"column":2,"index":59},"end":{"line":7,"column":3,"index":60}}, | ||
"name": "a" | ||
} | ||
}, | ||
"children": [ | ||
{ | ||
"type": "JSXText", | ||
"start":3,"end":57,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":7,"column":0,"index":57}}, | ||
"extra": { | ||
"rawValue": "\n &\n &a;\n & ;\n &xamp;\n �_0;\n", | ||
"raw": "\n &\n &a;\n & ;\n &xamp;\n �_0;\n" | ||
}, | ||
"value": "\n &\n &a;\n & ;\n &xamp;\n �_0;\n" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/jsx/html-entities/no-object-prototype/input.js
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 @@ | ||
<a>&valueOf;</a> |
52 changes: 52 additions & 0 deletions
52
packages/babel-parser/test/fixtures/jsx/html-entities/no-object-prototype/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,52 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":16,"index":16}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":16,"index":16}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":16,"index":16}}, | ||
"expression": { | ||
"type": "JSXElement", | ||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":16,"index":16}}, | ||
"openingElement": { | ||
"type": "JSXOpeningElement", | ||
"start":0,"end":3,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":3,"index":3}}, | ||
"name": { | ||
"type": "JSXIdentifier", | ||
"start":1,"end":2,"loc":{"start":{"line":1,"column":1,"index":1},"end":{"line":1,"column":2,"index":2}}, | ||
"name": "a" | ||
}, | ||
"attributes": [], | ||
"selfClosing": false | ||
}, | ||
"closingElement": { | ||
"type": "JSXClosingElement", | ||
"start":12,"end":16,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":16,"index":16}}, | ||
"name": { | ||
"type": "JSXIdentifier", | ||
"start":14,"end":15,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":15,"index":15}}, | ||
"name": "a" | ||
} | ||
}, | ||
"children": [ | ||
{ | ||
"type": "JSXText", | ||
"start":3,"end":12,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":1,"column":12,"index":12}}, | ||
"extra": { | ||
"rawValue": "&valueOf;", | ||
"raw": "&valueOf;" | ||
}, | ||
"value": "&valueOf;" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |