From 6dbfa308b80c7dc3f08a975a517cc434d3bd1e68 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 13 Feb 2025 12:41:27 -0700 Subject: [PATCH] Do not process `&`-entities that don't end in `;` Same fix as , because both libraries use the same HTML entity parser in the same incorrect way. --- lib/rules_inline/entity.mjs | 4 ++-- test/fixtures/markdown-it/commonmark_extras.txt | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/rules_inline/entity.mjs b/lib/rules_inline/entity.mjs index e65191d..16aa8b2 100644 --- a/lib/rules_inline/entity.mjs +++ b/lib/rules_inline/entity.mjs @@ -1,6 +1,6 @@ // Process html entity - {, ¯, ", ... -import { decodeHTML } from 'entities' +import { decodeHTMLStrict } from 'entities' import { isValidEntityCode, fromCodePoint } from '../common/utils.mjs' const DIGITAL_RE = /^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i @@ -33,7 +33,7 @@ export default function entity (state, silent) { } else { const match = state.src.slice(pos).match(NAMED_RE) if (match) { - const decoded = decodeHTML(match[0]) + const decoded = decodeHTMLStrict(match[0]) if (decoded !== match[0]) { if (!silent) { const token = state.push('text_special', '', 0) diff --git a/test/fixtures/markdown-it/commonmark_extras.txt b/test/fixtures/markdown-it/commonmark_extras.txt index 558c011..d7feb13 100644 --- a/test/fixtures/markdown-it/commonmark_extras.txt +++ b/test/fixtures/markdown-it/commonmark_extras.txt @@ -740,3 +740,19 @@ Html in image description .

text <textarea> text

. + + +https://github.com/commonmark/commonmark.js/pull/279 + +. +¶g; + +¶ + +¶ +. +

&parag;

+

&para

+

ΒΆ

+. +