Merge branch 'master' of github.com:calzoneman/sync
This commit is contained in:
commit
0db5f64b15
2 changed files with 58 additions and 17 deletions
16
lib/xss.js
16
lib/xss.js
|
|
@ -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(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, "\"")
|
||||
.replace(/&/g, "&");
|
||||
return str;
|
||||
}
|
||||
|
||||
module.exports.sanitizeHTML = sanitizeHTML;
|
||||
module.exports.sanitizeText = sanitizeText;
|
||||
module.exports.decodeText = decodeText;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue