return null if text passed is null. Don't try to unescape it!

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
Adam Warner
2020-11-08 17:35:24 +00:00
parent 3739c1600e
commit 78f88d9633

View File

@@ -17,6 +17,8 @@ function escapeHtml(text) {
"'": "&#039;"
};
if (text === null) return null;
return text.replace(/[&<>"']/g, function (m) {
return map[m];
});
@@ -31,6 +33,8 @@ function unescapeHtml(text) {
"&#039;": "'"
};
if (text === null) return null;
return text.replace(/&(?:amp|lt|gt|quot|#039);/g, function (m) {
return map[m];
});