fix(compiler): update unparsable character reference entity error messages (#38319)
Within an angular template, when a character entity is unable to be parsed, previously a generic unexpected character error was thrown. This does not properly express the issue that was discovered as the issue is actually caused by the discovered character making the whole of the entity unparsable. The compiler will now instead inform via the error message what string was attempted to be parsed and what it was attempted to be parsed as. Example, for this template: ``` <p> ģp </p> ``` Before this change: `Unexpected character "p"` After this change: `Unable to parse entity "ģp" - hexadecimal character reference entities must end with ";"` Fixes #26067 PR Close #38319
This commit is contained in:

committed by
Alex Rickabaugh

parent
9c5fc1693a
commit
cea46786a2
@ -477,12 +477,16 @@ import {ParseLocation, ParseSourceFile, ParseSourceSpan} from '../../src/parse_u
|
||||
lex.TokenType.TEXT,
|
||||
'Unknown entity "tbo" - use the "&#<decimal>;" or "&#x<hex>;" syntax', '0:0'
|
||||
]]);
|
||||
expect(tokenizeAndHumanizeErrors('sdf;')).toEqual([
|
||||
[lex.TokenType.TEXT, 'Unexpected character "s"', '0:3']
|
||||
]);
|
||||
expect(tokenizeAndHumanizeErrors('
sdf;')).toEqual([
|
||||
[lex.TokenType.TEXT, 'Unexpected character "s"', '0:4']
|
||||
]);
|
||||
expect(tokenizeAndHumanizeErrors('sdf;')).toEqual([[
|
||||
lex.TokenType.TEXT,
|
||||
'Unable to parse entity "s" - decimal character reference entities must end with ";"',
|
||||
'0:4'
|
||||
]]);
|
||||
expect(tokenizeAndHumanizeErrors('
sdf;')).toEqual([[
|
||||
lex.TokenType.TEXT,
|
||||
'Unable to parse entity "
s" - hexadecimal character reference entities must end with ";"',
|
||||
'0:5'
|
||||
]]);
|
||||
|
||||
expect(tokenizeAndHumanizeErrors('઼')).toEqual([
|
||||
[lex.TokenType.TEXT, 'Unexpected character "EOF"', '0:6']
|
||||
|
Reference in New Issue
Block a user