Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/parser/lib/lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const EntityRef = createToken({

const CharRef = createToken({
name: "CharRef",
pattern: /&#\d+;|&#x[a-fA-F0-9]/,
pattern: /&#\d+;|&#x[a-fA-F0-9]+;/,
});

const SEA_WS = createToken({
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"scripts": {
"ci": "npm-run-all clean type-check coverage:*",
"clean": "rimraf ./coverage ./nyc_output",
"test": "mocha \"./test/**/*spec.js\"",
"test": "mocha -reporter-option maxDiffSize=65536 \"./test/**/*spec.js\"",
"coverage:run": "nyc mocha \"./test/**/*spec.js\"",
"coverage:check": "nyc check-coverage --lines 100 --branches 100 --statements 100 --functions 100",
"snapshots:update": "node ./scripts/update-snapshots.js",
Expand Down
12 changes: 12 additions & 0 deletions packages/parser/test/snapshots/invalid/entity-char-ref/input.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<note>
&foo
&foo ;

&#1234
&#1234 ;
&#12Y3;

&#x123ABC
&#x123ABC ;
&#x123YBC;
</note>
206 changes: 206 additions & 0 deletions packages/parser/test/snapshots/invalid/entity-char-ref/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
module.exports = {
cst: {
name: "document",
children: {
element: [
{
name: "element",
children: {
OPEN: [
{ image: "<", startOffset: 0, endOffset: 0, tokenType: "OPEN" },
],
Name: [
{
image: "note",
startOffset: 1,
endOffset: 4,
tokenType: "Name",
},
],
START_CLOSE: [
{ image: ">", startOffset: 5, endOffset: 5, tokenType: "CLOSE" },
],
content: [
{
name: "content",
children: {
chardata: [
{
name: "chardata",
children: {
SEA_WS: [
{
image: "\n ",
startOffset: 6,
endOffset: 8,
tokenType: "SEA_WS",
},
],
},
location: { startOffset: 6, endOffset: 8 },
},
{
name: "chardata",
children: {
TEXT: [
{
image: "foo\n ",
startOffset: 10,
endOffset: 15,
tokenType: "TEXT",
},
],
},
location: { startOffset: 10, endOffset: 15 },
},
{
name: "chardata",
children: {
TEXT: [
{
image: "foo ;\n\n ",
startOffset: 17,
endOffset: 25,
tokenType: "TEXT",
},
],
},
location: { startOffset: 17, endOffset: 25 },
},
{
name: "chardata",
children: {
TEXT: [
{
image: "#1234\n ",
startOffset: 27,
endOffset: 34,
tokenType: "TEXT",
},
],
},
location: { startOffset: 27, endOffset: 34 },
},
{
name: "chardata",
children: {
TEXT: [
{
image: "#1234 ;\n ",
startOffset: 36,
endOffset: 45,
tokenType: "TEXT",
},
],
},
location: { startOffset: 36, endOffset: 45 },
},
{
name: "chardata",
children: {
TEXT: [
{
image: "#12Y3;\n\n ",
startOffset: 47,
endOffset: 56,
tokenType: "TEXT",
},
],
},
location: { startOffset: 47, endOffset: 56 },
},
{
name: "chardata",
children: {
TEXT: [
{
image: "#x123ABC\n ",
startOffset: 58,
endOffset: 68,
tokenType: "TEXT",
},
],
},
location: { startOffset: 58, endOffset: 68 },
},
{
name: "chardata",
children: {
TEXT: [
{
image: "#x123ABC ;\n ",
startOffset: 70,
endOffset: 82,
tokenType: "TEXT",
},
],
},
location: { startOffset: 70, endOffset: 82 },
},
{
name: "chardata",
children: {
TEXT: [
{
image: "#x123YBC;\n",
startOffset: 84,
endOffset: 93,
tokenType: "TEXT",
},
],
},
location: { startOffset: 84, endOffset: 93 },
},
],
},
location: { startOffset: 6, endOffset: 93 },
},
],
SLASH_OPEN: [
{
image: "</",
startOffset: 94,
endOffset: 95,
tokenType: "SLASH_OPEN",
},
],
END_NAME: [
{
image: "note",
startOffset: 96,
endOffset: 99,
tokenType: "Name",
},
],
END: [
{
image: ">",
startOffset: 100,
endOffset: 100,
tokenType: "CLOSE",
},
],
},
location: { startOffset: 0, endOffset: 100 },
},
],
misc: [
{
name: "misc",
children: {
SEA_WS: [
{
image: "\n",
startOffset: 101,
endOffset: 101,
tokenType: "SEA_WS",
},
],
},
location: { startOffset: 101, endOffset: 101 },
},
],
},
location: { startOffset: 0, endOffset: 101 },
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const {
executeInValidSampleTest,
testNameFromDir,
} = require("../../../sample-test");
describe(`${testNameFromDir(__dirname)}`, () => {
executeInValidSampleTest(__dirname);
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<note>
&to;
&#1234;
&#x123ABC;
<from>Tim</from>
</note>
Loading