Skip to content

Commit 0214059

Browse files
fix(html): require lowercase x in XML hexadecimal character references
1 parent 85300a5 commit 0214059

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎lib/html/syntax-parser.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5726,7 +5726,7 @@ const isXmlChar = (code) =>
57265726
*/
57275727
const decodeXmlEntities = (value) =>
57285728
value.replace(
5729-
/&(?:#(?:x([\da-f]+)|(\d+))|([a-z]+));/gi,
5729+
/&(?:#(?:x([\da-fA-F]+)|(\d+))|([a-z]+));/g,
57305730
(match, hex, decimal, name) => {
57315731
if (name !== undefined) {
57325732
return Object.prototype.hasOwnProperty.call(XML_NAMED_REFERENCES, name)

‎test/unitCases/HtmlSyntax.unittest.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3471,6 +3471,16 @@ describe("parseHtml", () => {
34713471
});
34723472
});
34733473

3474+
it("should require a lowercase hexadecimal marker", () => {
3475+
const root = /** @type {MatElement} */ (
3476+
parseXml("<root>&#x4A;&#X4A;</root>").children[0]
3477+
);
3478+
expect(root.children[0]).toMatchObject({
3479+
type: NodeType.Text,
3480+
data: "J&#X4A;"
3481+
});
3482+
});
3483+
34743484
it("should not decode HTML-only or differently-cased entity names", () => {
34753485
const root = /** @type {MatElement} */ (
34763486
parseXml("<root>&nbsp;&AMP;&amp;</root>").children[0]

0 commit comments

Comments
 (0)