Skip to content

Commit 4949a92

Browse files
fix(html): require lowercase x in XML hexadecimal character references
1 parent a3d0216 commit 4949a92

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
@@ -5764,7 +5764,7 @@ const isXmlChar = (code) =>
57645764
*/
57655765
const decodeXmlEntities = (value) =>
57665766
value.replace(
5767-
/&(?:#(?:x([\da-f]+)|(\d+))|([a-z]+));/gi,
5767+
/&(?:#(?:x([\da-fA-F]+)|(\d+))|([a-z]+));/g,
57685768
(match, hex, decimal, name) => {
57695769
if (name !== undefined) {
57705770
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)