Work on text filter

This commit is contained in:
Calvin Montgomery 2013-11-05 10:37:50 -06:00
parent 33d1075d44
commit 7318200878
2 changed files with 58 additions and 17 deletions

View file

@ -262,4 +262,20 @@ function sanitizeText(str) {
return str;
}
function decodeText(str) {
str = str.replace(/&#([0-9]{2,4});?/g, function (m, p1) {
return String.fromCharCode(parseInt(p1));
});
str = str.replace(/&#x([0-9a-f]{2,4});?/ig, function (m, p1) {
return String.fromCharCode(parseInt(p1, 16));
});
str = str.replace(/&lt;/g, "<")
.replace(/&gt;/g, ">")
.replace(/&quot;/g, "\"")
.replace(/&amp;/g, "&");
return str;
}
module.exports.sanitizeHTML = sanitizeHTML;
module.exports.sanitizeText = sanitizeText;
module.exports.decodeText = decodeText;