diff --git a/src/Renderer.js b/src/Renderer.js index 7c36a7554e..5fe915dd85 100644 --- a/src/Renderer.js +++ b/src/Renderer.js @@ -32,7 +32,7 @@ export class Renderer { return '
'
       + (escaped ? code : escape(code, true))
       + '
\n'; @@ -170,7 +170,7 @@ export class Renderer { if (href === null) { return text; } - let out = '"']/; -const escapeReplace = /[&<>"']/g; -const escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/; -const escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g; +const escapeReplace = new RegExp(escapeTest.source, 'g'); +const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/; +const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, 'g'); const escapeReplacements = { '&': '&', '<': '<', diff --git a/test/specs/commonmark/commonmark.0.30.json b/test/specs/commonmark/commonmark.0.30.json index 261eb25c9e..43f433bb26 100644 --- a/test/specs/commonmark/commonmark.0.30.json +++ b/test/specs/commonmark/commonmark.0.30.json @@ -221,8 +221,7 @@ "example": 28, "start_line": 691, "end_line": 701, - "section": "Entity and numeric character references", - "shouldFail": true + "section": "Entity and numeric character references" }, { "markdown": "©\n", @@ -272,8 +271,7 @@ "example": 34, "start_line": 752, "end_line": 759, - "section": "Entity and numeric character references", - "shouldFail": true + "section": "Entity and numeric character references" }, { "markdown": "`föö`\n", diff --git a/test/specs/gfm/commonmark.0.30.json b/test/specs/gfm/commonmark.0.30.json index 6cb2e60a50..5089b6aca3 100644 --- a/test/specs/gfm/commonmark.0.30.json +++ b/test/specs/gfm/commonmark.0.30.json @@ -221,8 +221,7 @@ "example": 28, "start_line": 691, "end_line": 701, - "section": "Entity and numeric character references", - "shouldFail": true + "section": "Entity and numeric character references" }, { "markdown": "©\n", @@ -272,8 +271,7 @@ "example": 34, "start_line": 752, "end_line": 759, - "section": "Entity and numeric character references", - "shouldFail": true + "section": "Entity and numeric character references" }, { "markdown": "`föö`\n",