Handle leading zeros in quote html entity (#4623)

This commit is contained in:
Kerry Liu
2020-02-05 00:17:16 -08:00
committed by GitHub
parent 3f585df05c
commit 588bf3e20d
2 changed files with 8 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ const htmlUnescapes = {
}
/** Used to match HTML entities and HTML characters. */
const reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g
const reEscapedHtml = /&(?:amp|lt|gt|quot|#(0+)?39);/g
const reHasEscapedHtml = RegExp(reEscapedHtml.source)
/**
@@ -31,7 +31,7 @@ const reHasEscapedHtml = RegExp(reEscapedHtml.source)
*/
function unescape(string) {
return (string && reHasEscapedHtml.test(string))
? string.replace(reEscapedHtml, (entity) => htmlUnescapes[entity])
? string.replace(reEscapedHtml, (entity) => (htmlUnescapes[entity] || "'") )
: (string || '')
}