Skip to content

Commit 730d329

Browse files
committed
fix(compiler-core): relax error on unknown entities
close #663
1 parent 93eba43 commit 730d329

File tree

4 files changed

+3
-86
lines changed

4 files changed

+3
-86
lines changed

packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap

-69
Original file line numberDiff line numberDiff line change
@@ -6956,75 +6956,6 @@ Object {
69566956
}
69576957
`;
69586958
6959-
exports[`compiler: parse Errors UNKNOWN_NAMED_CHARACTER_REFERENCE <template>&unknown;</template> 1`] = `
6960-
Object {
6961-
"cached": 0,
6962-
"children": Array [
6963-
Object {
6964-
"children": Array [
6965-
Object {
6966-
"content": "&unknown;",
6967-
"loc": Object {
6968-
"end": Object {
6969-
"column": 20,
6970-
"line": 1,
6971-
"offset": 19,
6972-
},
6973-
"source": "&unknown;",
6974-
"start": Object {
6975-
"column": 11,
6976-
"line": 1,
6977-
"offset": 10,
6978-
},
6979-
},
6980-
"type": 2,
6981-
},
6982-
],
6983-
"codegenNode": undefined,
6984-
"isSelfClosing": false,
6985-
"loc": Object {
6986-
"end": Object {
6987-
"column": 31,
6988-
"line": 1,
6989-
"offset": 30,
6990-
},
6991-
"source": "<template>&unknown;</template>",
6992-
"start": Object {
6993-
"column": 1,
6994-
"line": 1,
6995-
"offset": 0,
6996-
},
6997-
},
6998-
"ns": 0,
6999-
"props": Array [],
7000-
"tag": "template",
7001-
"tagType": 3,
7002-
"type": 1,
7003-
},
7004-
],
7005-
"codegenNode": undefined,
7006-
"components": Array [],
7007-
"directives": Array [],
7008-
"helpers": Array [],
7009-
"hoists": Array [],
7010-
"imports": Array [],
7011-
"loc": Object {
7012-
"end": Object {
7013-
"column": 31,
7014-
"line": 1,
7015-
"offset": 30,
7016-
},
7017-
"source": "<template>&unknown;</template>",
7018-
"start": Object {
7019-
"column": 1,
7020-
"line": 1,
7021-
"offset": 0,
7022-
},
7023-
},
7024-
"type": 0,
7025-
}
7026-
`;
7027-
70286959
exports[`compiler: parse Errors X_INVALID_END_TAG <svg><![CDATA[</div>]]></svg> 1`] = `
70296960
Object {
70306961
"cached": 0,

packages/compiler-core/__tests__/parse.spec.ts

-11
Original file line numberDiff line numberDiff line change
@@ -2594,17 +2594,6 @@ foo
25942594
]
25952595
}
25962596
],
2597-
UNKNOWN_NAMED_CHARACTER_REFERENCE: [
2598-
{
2599-
code: '<template>&unknown;</template>',
2600-
errors: [
2601-
{
2602-
type: ErrorCodes.UNKNOWN_NAMED_CHARACTER_REFERENCE,
2603-
loc: { offset: 10, line: 1, column: 11 }
2604-
}
2605-
]
2606-
}
2607-
],
26082597
X_INVALID_END_TAG: [
26092598
{
26102599
code: '<template></div></template>',

packages/compiler-core/src/errors.ts

-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export const enum ErrorCodes {
5757
UNEXPECTED_NULL_CHARACTER,
5858
UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME,
5959
UNEXPECTED_SOLIDUS_IN_TAG,
60-
UNKNOWN_NAMED_CHARACTER_REFERENCE,
6160

6261
// Vue-specific parse errors
6362
X_INVALID_END_TAG,
@@ -141,7 +140,6 @@ export const errorMessages: { [code: number]: string } = {
141140
[ErrorCodes.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME]:
142141
"'<?' is allowed only in XML context.",
143142
[ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG]: "Illegal '/' in tags.",
144-
[ErrorCodes.UNKNOWN_NAMED_CHARACTER_REFERENCE]: 'Unknown entity name.',
145143

146144
// Vue-specific parse errors
147145
[ErrorCodes.X_INVALID_END_TAG]: 'Invalid end tag.',

packages/compiler-core/src/parse.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,8 @@ function parseTextData(
820820

821821
if (head[0] === '&') {
822822
// Named character reference.
823-
let name = '',
824-
value: string | undefined = undefined
823+
let name = ''
824+
let value: string | undefined = undefined
825825
if (/[0-9a-z]/i.test(rawText[1])) {
826826
for (
827827
let length = context.options.maxCRNameLength;
@@ -836,7 +836,7 @@ function parseTextData(
836836
if (
837837
mode === TextModes.ATTRIBUTE_VALUE &&
838838
!semi &&
839-
/[=a-z0-9]/i.test(rawText[1 + name.length] || '')
839+
/[=a-z0-9]/i.test(rawText[name.length + 1] || '')
840840
) {
841841
decodedText += '&' + name
842842
advance(1 + name.length)
@@ -851,7 +851,6 @@ function parseTextData(
851851
}
852852
}
853853
} else {
854-
emitError(context, ErrorCodes.UNKNOWN_NAMED_CHARACTER_REFERENCE)
855854
decodedText += '&' + name
856855
advance(1 + name.length)
857856
}

0 commit comments

Comments
 (0)