From 31c77995d59c380a94b9e24e88543b36d050ca9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Pocztarski?= Date: Fri, 15 Jul 2016 13:08:12 +0200 Subject: [PATCH] add optional semicolon in html entities regex and make non-capturing group out of (\w+) that was not used in the function (only the entire surrounding group is used as a whole) The semicolon is outside of the capturing group so the input to the function is the same as before. See this comment: https://github.com/chjj/marked/pull/592/files/2cff859#r70888592 --- lib/marked.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/marked.js b/lib/marked.js index 089369f0..07027288 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -1095,7 +1095,7 @@ function escape(html, encode) { function unescape(html) { // explicitly match decimal, hex, and named HTML entities - return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(\w+))/g, function(_, n) { + return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function(_, n) { n = n.toLowerCase(); if (n === 'colon') return ':'; if (n.charAt(0) === '#') {