Skip to content

Commit

Permalink
add optional semicolon in html entities regex
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rsp committed Jul 15, 2016
1 parent 2cff859 commit 31c7799
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) === '#') {
Expand Down

0 comments on commit 31c7799

Please sign in to comment.