Skip to content

Commit

Permalink
Do not process &-entities that don't end in ;
Browse files Browse the repository at this point in the history
Fixes #278
  • Loading branch information
notriddle authored and jgm committed Jan 28, 2024
1 parent c7aef33 commit 0f94755
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/common.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

import encode from "mdurl/encode.js";
import { decodeHTML } from "entities";
import { decodeHTMLStrict } from "entities";

var C_BACKSLASH = 92;

Expand Down Expand Up @@ -58,7 +58,7 @@ var unescapeChar = function(s) {
if (s.charCodeAt(0) === C_BACKSLASH) {
return s.charAt(1);
} else {
return decodeHTML(s);
return decodeHTMLStrict(s);
}
};

Expand Down
4 changes: 2 additions & 2 deletions lib/inlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Node from "./node.js";
import * as common from "./common.js";
import fromCodePoint from "./from-code-point.js";
import { decodeHTML } from "entities";
import { decodeHTMLStrict } from "entities";
import "string.prototype.repeat"; // Polyfill for String.prototype.repeat

var normalizeURI = common.normalizeURI;
Expand Down Expand Up @@ -773,7 +773,7 @@ var removeBracket = function() {
var parseEntity = function(block) {
var m;
if ((m = this.match(reEntityHere))) {
block.appendChild(text(decodeHTML(m)));
block.appendChild(text(decodeHTMLStrict(m)));
return true;
} else {
return false;
Expand Down
13 changes: 13 additions & 0 deletions test/regression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,16 @@ x <- 1
<pre><code class="language-r">x &lt;- 1
</code></pre>
````````````````````````````````

#278
```````````````````````````````` example
&parag;

&para

&para;
.
<p>&amp;parag;</p>
<p>&amp;para</p>
<p>¶</p>
````````````````````````````````

0 comments on commit 0f94755

Please sign in to comment.